g18c DD-WRT Novice
Joined: 10 May 2007 Posts: 19
|
Posted: Fri Jun 29, 2007 9:28 Post subject: PPTP client set default route on 'ip-up' - editing scripts |
|
Hi, can anyone tell me how i can set all traffic to be routed through ppp0 when the link is bought up?
PPTP is running /tmp/pptpd_client/ip-up script on completion of the ppp link. How can i edit this to set
a) a host route to the vpn server itself out br0
b) set ppp0 as the default route
i.e.
route add -host 200.200.100.100 gw 192.168.1.1 dev br0
route add default dev ppp0
i cant edit the script as its in memory and not be persisted. i presume its unpacked into /tmp/ during boot, is there any way i can edit this without recompiling the binary?
are there any other options with startup scripts etc?
Thanks |
|
g18c DD-WRT Novice
Joined: 10 May 2007 Posts: 19
|
Posted: Fri Jun 29, 2007 10:22 Post subject: |
|
I have seen this link: http://www.dd-wrt.com/wiki/index.php/Script_Execution#Script_types
but i dont fully understand howto use it in the case of the ppp link. Would i simply place /jffs/etc/config/myscript.ipup and i should be good to go, getting called automatically when the link comes up?
What if i wanted to extend support for multiple pptp clients? How would i know which interface is calling this script?
I am confused however, the wiki states that scripts are run in the following locations:
/etc/config/
/jffs/etc/config/
/mmc/etc/config/
/tmp/etc/config/
However, when running pptp it clearly shows on the shell output it is running /tmp/pptpd_client/ip-up, where this is configured in /tmp/pptpd_client/options.vpn with the line 'ip-up-script /tmp/pptpd_client/ip-up
'.
It seems the script /etc/config/pptpd_client.ip-up is redundant and not getting called at all, furthermore it seems that pptp is controlling which scripts are called, which is not what the wiki says? What would be the best way for me to get my scripts to run?
Code: | ~ # cat /etc/config/pptpd_client.ip-up
#!/bin/sh
REMOTESUB=$(/usr/sbin/nvram get pptpd_client_srvsub)
REMOTENET=$(/usr/sbin/nvram get pptpd_client_srvsubmsk)
case "$6" in
kelokepptpd)
/sbin/route add -net $REMOTESUB netmask $REMOTENET dev $1
/usr/sbin/iptables --insert OUTPUT --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $1
/usr/sbin/iptables --insert INPUT --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $1
/usr/sbin/iptables --insert FORWARD --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $1
/usr/sbin/iptables --insert FORWARD --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $1
/usr/sbin/iptables --insert FORWARD --protocol tcp --tcp-flags SYN,RST SYN --jump TCPMSS --clamp-mss-to-pmtu
if [ "$(/usr/sbin/nvram get pptpd_client_nat)" = "1" ]; then
/usr/sbin/iptables --table nat --append POSTROUTING --out-interface $1 --jump MASQUERADE
fi
;;
*)
esac
exit 0 |
Code: | ~ # cat /tmp/pptpd_client/ip-up
#!/bin/sh
REMOTESUB=$(/usr/sbin/nvram get pptpd_client_srvsub)
REMOTENET=$(/usr/sbin/nvram get pptpd_client_srvsubmsk)
case "$6" in
kelokepptpd)
/sbin/route add -net $REMOTESUB netmask $REMOTENET dev $1
/usr/sbin/iptables --insert OUTPUT --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $1
/usr/sbin/iptables --insert INPUT --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $1
/usr/sbin/iptables --insert FORWARD --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $1
/usr/sbin/iptables --insert FORWARD --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $1
/usr/sbin/iptables --insert FORWARD --protocol tcp --tcp-flags SYN,RST SYN --jump TCPMSS --clamp-mss-to-pmtu
if [ "$(/usr/sbin/nvram get pptpd_client_nat)" = "1" ]; then
/usr/sbin/iptables --table nat --append POSTROUTING --out-interface $1 --jump MASQUERADE
fi
;;
*)
esac
exit 0 |
thanks |
|