Jump to content


Photo
- - - - -

Accepting dns push on dd-wrt router

dd-wrt dns dnsmasq

  • Please log in to reply
No replies to this topic

#1 dysprosium156

dysprosium156

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 22 January 2016 - 11:51 AM

The resolv-conf-update script uses bash-specific variable substitutions so won't work on my dd-wrt router, firmware v3.0-r28112 so, having followed the Air setup guide, I've made the following changes to action the pushed dns value.

 

- remove the static dns entry for 10.x.0.1 from the Basic setup page. I do have an OpenNIC static dns ip there too.

- added the following script to the Admin,Commands,Startup to edit the resolver config file

# Ensure client enabled
[ `nvram get openvpncl_enable`  ] || exit

OVPN='/tmp/openvpncl'
DNSMQ='/tmp/dnsmasq.conf'

echo "#!/bin/sh
# Fetch dnsmasq's 'resolv.conf'
RSLV=\`sed '/resolv-file/!d ; s/.*=//' $DNSMQ\`

# Edit resolver conf - (only works for single pushed dns server)
case \$script_type in
up)
  # Get pushed dns from env
  PDNS=\`set | sed '/foreign_option_.*dhcp-option DNS /!d ; s/.* \([0-9.]*\).*/nameserver \1/'\`
  sed -i \"1s/^/\$PDNS\n/\" \$RSLV
  echo \$PDNS >$OVPN/pdns
;;
down)
  PDNS=\`set | cat $OVPN/pdns\`
  sed -i \"/\$PDNS/d\" \$RSLV
;;
esac
" > $OVPN/updown.sh

# Hack redundant, problem rules
sed -i 's/\(.*-I INPUT\)\(.*j \).*/\1 2 \2REJECT/' $OVPN/route-*.sh
sed -i 's/\(.*-D INPUT\)\(.*j \).*/\1 \2REJECT/' $OVPN/route-*.sh
sed -i '/FORWARD/d' $OVPN/route-*.sh

chmod 600 $OVPN/*
chmod 700 $OVPN/*.sh

killall openvpn ; openvpn --config /tmp/openvpncl/openvpn.conf --route-up /tmp/openvpncl/route-up.sh --down-pre /tmp/openvpncl/route-down.sh --daemon




dnsmasq polls its resolver file, resolv.dnsmasq, and acts on changes, so doesn't require any explicit update instructions.

​Note: **added** openvpn restart  -  there's currently a timing issue (updown.sh isn't created until after the initial start of openvpn, which consequently fails)  

 

- add the following directives to the openvpn config

up /tmp/openvpncl/updown.sh
down /tmp/openvpncl/updown.sh

- check it works by visiting ipleak.net or look at /tmp/resolv.dnsmasq on the dd-wrt


Edited by dysprosium156, 02 April 2016 - 07:51 AM.






Similar Topics Collapse


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

Servers online. Online Sessions: 15772 - BW: 59658 Mbit/sYour IP: 54.146.227.92Guest Access.