Results 1 to 3 of 3

Thread: How to route certain IP subnets via tun and keep other route via wlan?

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Beans
    42
    Distro
    Ubuntu 10.04 Lucid Lynx

    How to route certain IP subnets via tun and keep other route via wlan?

    Hi,

    I use vpnc to connect to my company's vpn. But vpnc's script modifies my routing table and after connecting, all my traffic goes via tun0 interface - and this is not good as it is much slower + some services on our vpn's network are blocked.

    I would need to let only certain subnet to be routed via tun0 and the rest via my wlan0/default gateway.

    This is my default routing table withou vpn connected:
    Code:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.1.106   0.0.0.0         UG    0      0        0 wlan0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
    192.168.1.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0

    And this is after connectiong to vpn (just for privacy, I marked some parts of IP with xx):
    Code:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 tun0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
    172.xx.xx.0     0.0.0.0         255.255.255.0   U     0      0        0 tun0
    192.168.1.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0
    213.xx.xx.xx    192.168.1.106   255.255.255.255 UGH   0      0        0 wlan0
    So, how would I correct routing table to route 213.0.0.0 + 172.0.0.0 via tun0 and let other IPs route via wlan0 ? I am not good in this routing stuff, so I would appreciate some help here
    Thanks!

  2. #2
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    7,701

    Re: How to route certain IP subnets via tun and keep other route via wlan?

    Something like these commands (after the VPN is brought up) should do the trick:
    Code:
    sudo route del default
    sudo route add default gw 192.168.1.106
    sudo route add -net 213.0.0.0 netmask 255.0.0.0 tun0
    sudo route add -net 172.0.0.0 netmask 255.0.0.0 tun0
    I would probably put them in a little script, and maybe even make a launcher for them if I needed to do it frequently.

  3. #3
    Join Date
    Apr 2006
    Beans
    42
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to route certain IP subnets via tun and keep other route via wlan?

    Thanks much! That simply works for me.

Tags for this Thread

Bookmarks

Posting Permissions

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