Re: source based routing help needed



Hello,

Ashish Shukla wrote :

I'm little confused here. if you don't make tunnel 'tun1' default
route, and make 'eth0' instead what happens. I assume following
happens, but I'm not sure, so correct me if I'm wrong:

tun1 - 192.168.1.1/24, eth0 - 10.0.2.1/24 (default route)

so if webserver listening on 192.168.1.1 receives a packet from
10.3.4.5 on tun1, when replies back, reply goes out via eth0 (the
gateway), since 10.3.4.5 belongs to none of the local networks. So
there is absolutely no relation between routing of packet from
10.3.4.5 and packet to 10.3.4.5, right ?

I guess that there is some NAT involved, so routing has to be symmetrical.

Jack> How can I get source based routing to work on just the eth0 / tun1 Jack> interfaces?

You need to setup some routing rules.

$tun1_gateway - tun1 gateway IPv4 address
$eth0_gateway - eth0 gateway IPv4 address
$tun1_ip - tun1 IPv4 address
$eth0_ip - eth0 IPv4 address

----8<----8<----
root@host # ip route add default via $tun1_gateway table 100
root@host # ip route add default via $eth0_gateway table 101
root@host # ip rule add from $tun1_ip table 100
root@host # ip rule add from $eth0_ip table 101
---->8---->8----

Above commands will create 2 source based rules, which basically
inteneds to route outgoing packet via the interface corresponding to
the packet's source address.

To do things properly you need to add routes overriding the source-based default routes in each table when the destination is in a directly attached network :

$eth0_subnet - IP subnet on eth0
$tun1_subnet - IP subnet or peer address on tun1

ip route add $eth0_subnet dev eth0 table 100
ip route add $tun1_subnet dev tun1 table 101
.



Relevant Pages

  • Re: Linux is Driving me $#@!!!! nutz!!!
    ... :Doing a route call from terminal ... via nic card on eth0. ... time since I had to configure a PPP connection, ... from the command line. ...
    (rec.crafts.metalworking)
  • Re: Ethernet order
    ... > I added this Linux box on the network to play with and wanted it to ... connect to the internet via that Westell device, ... The last route, with some sort of "catch all" destination 0.0.0.0, is ... Your ISP's router would go via eth0 to that device. ...
    (comp.os.linux.networking)
  • Re: [opensuse] Suse 10.2 +two network cards (Not yet solved)
    ... then set the eth0 as it was default from the installation. ... set eth1 DNS servers etc. so DHCP would not update them. ... Also have figure out where to put the route command ...
    (SuSE)
  • Re: DNS or network problem
    ... UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 ... The first thing that leaps out at me is the fact that eth0 and eth1 ... Because all your routes passes through eth1, and not eth0, I ...
    (Fedora)
  • Re: Slow browsing with cable modem
    ... The netmask above ... these results for my eth0 interface: ... route add default gw 192.168.1.1 eth0 ... > with network configuration problems, so it's only fair to be rightly ...
    (comp.os.linux.networking)