Jump to content
Not connected, Your IP: 52.14.126.74
Sign in to follow this  
dysprosium156

Accepting dns push on dd-wrt router

Recommended Posts

Posted ... (edited)

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Security Check
    Play CAPTCHA Audio
    Refresh Image
Sign in to follow this  

×
×
  • Create New...