Find the answer to your Linux question:
Results 1 to 3 of 3

Thread: dynamic routing

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    dynamic routing


    I need your help. I am implementing Mobile IP with VTUN. Main idea is to route all data through tun device via default gw (HA (or VPN server) tun dev ip). Except of course, "true" conection of VTUN.

    Everything works great then I am stationary. Internet data goes through tun dev.

    This is my client side configuration:

    up {

    ifconfig "%% pointopoint mtu 1450";

    route "add gw";
    route "del default";
    route "add default gw";

    }; is my subnet GW. is server's IP. is server tun dev IP.
    Subnet mask is /24.

    Then i move to other subnet, i get my IP and default GW via DHCP.

    Then VTun initialize i want, that all data go through tun, so add line: add default gw

    Then problem occurs- VTun actual tunnel headers wants to go through this GW. Nonsense...

    And of course- connection terminates after some time.

    The Q:

    how to make so, that
    route "add gw {actual_gw}";
    this {actual_gw} must be dynamic.

    and all other data simply goes through gw

    I would really appreciate help. because I fell stuck here and without any ideas...


  2. #2
    I actually found solution, I made few script's. script to change GW with variable. works too, but has a nasty habit to loop if there is no default gw ir routing table.
    defaultgw=`route -n | grep '^0\.0\.\0\.0[ \t]' | awk '{print $2}'`
    if [ "$defaultgw" != "" ];
    	route add gw $defaultgw
    	route del default
    	route add default gw

    defaultgw2=`route -n | grep '^0\.0\.\0\.0[ \t]' | awk '{print $2}'`
    while [ "$defaultgw2" = "" ]
    defaultgw2=`route -n | grep '^0\.0\.\0\.0[ \t]' | awk '{print $2}'`

  3. #3
    My scripts are not so good actualy, I would like to ask- if there is any way to route, for example through main table, while where is higher priority table with default route?

    Something like that:

    "Higher table" to reach internet via VPN server

    Destination Gateway Genmask Flags Metric Ref Use Iface * UH 2 0 0 tun0
    default UG 0 0 0 tun0

    Main table
    Destination Gateway Genmask Flags Metric Ref Use Iface * U 2 0 0 wlan0
    default UG 0 0 0 wlan0

    Main Idea to route destination packets through main table.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts