1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running scripts from /jffs/etc/config/ on ppp up

Discussion in 'DD-WRT Firmware' started by g18c, Jun 29, 2007.

  1. g18c

    g18c LI Guru Member

    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:
    PHP:
    # 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 $
      
    /usr/sbin/iptables --insert OUTPUT --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $
      
    /usr/sbin/iptables --insert INPUT --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $
      
    /usr/sbin/iptables --insert FORWARD --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $
      
    /usr/sbin/iptables --insert FORWARD --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $
      
    /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 $--jump MASQUERADE 
      fi 
      
    ;; 
     *) 
    esac 
    exit 0

    Code:
    PHP:
    # 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 $
      
    /usr/sbin/iptables --insert OUTPUT --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $
      
    /usr/sbin/iptables --insert INPUT --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $
      
    /usr/sbin/iptables --insert FORWARD --source 0.0.0.0/0.0.0.0 --destination $REMOTESUB/$REMOTENET --jump ACCEPT --out-interface $
      
    /usr/sbin/iptables --insert FORWARD --source $REMOTESUB/$REMOTENET --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface $
      
    /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 $--jump MASQUERADE 
      fi 
      
    ;; 
     *) 
    esac 
    exit 0
    thanks
     

Share This Page