Selective routing (websites, ip's) through VPN

Discussion in 'Tomato Firmware' started by Mission, Aug 11, 2011.

  1. Mission

    Mission Networkin' Nut Member


    This is the script I've come up with (bits and pieces borrowed from posts on this forum)... after it starts thet internet stops working...VPN is up but it doesn't work...

    # get current default gateway
    DEFAULT_GW=`ip route show | awk '$1 == "default" && $2 == "via" {print $3}'`
    # get WAN gateway
    GW=`nvram get wan_gateway`
    # IP address of VPN gateway
    VPN_GW=`ip route show | awk '$2 == "dev" && $3 == "tun11" && $4 == "proto" {print $1}'`
    # List of IPs to reroute
    #IP_LIST=`nslookup | awk '$1 == "Address" && $3 != "" {print $3}'`
    # Loop
    #for IP in $IP_LIST
    ip route add $IP via $VPN_GW
    logger "Routing $IP via VPN gateway $VPN_GW"
    # route normal traffic thru WAN gateway
    ip route del default
    ip route add default via $DEFAULT_GW
    ip route flush cache
    The Router is WRT54GL with TomatoVPN 1.27

    VPN is blackVPN, OpenVPN...


    Please tell me what I'm doing wrong...

  2. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    All you have to do to have certain IPs go over the tunnel is add
    route <ip address>
    to your custom config.

    However, if your VPN server is pushing out a "redirect-gateway" directive to you, you'll have to somehow override that. You can either add "route-nopull" to your custom config and add any needed routes like I mentioned above, or you can have a route-up script that replaces the default gateway.
  3. Mission

    Mission Networkin' Nut Member

    I've tried everything you have mentioned... I've done everything in all of the post with the VPN keyword in them... that's why I'm asking for help...
  4. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    Okay... So what is happening when you try what I mentioned?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice