I have 2 interfaces: eth0
and wlan0
, each one connected to a different router. Their network specs are these:
eth0:
ip: 192.168.1.7
Gateway: 192.168.1.1
Submask: 255.255.255.0
wlan0:
ip: 192.168.2.21
Gateway: 192.168.2.1
Submask: 255.255.255.0
I've configured the routing this way:
ip route add table eth0 to 192.168.1.0/24 dev eth0 scope link
ip route add table eth0 default via 192.168.1.1 dev eth0
ip rule add from 192.168.1.7 table eth0
And the same for wlan0 using his values. So the routing output is:
ip rule
0: from all lookup local
32764: from 192.168.2.21 lookup wlan0
32765: from 192.168.1.7 lookup eth0
32766: from all lookup main
32767: from all lookup default
ip r s
default via 192.168.1.1 dev eth0 proto static
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.7 metric 1
192.168.2.0/24 dev wlan0 proto kernel scope link src 192.168.2.21 metric 9
ip r s table eth0
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 scope link
ip r s table wlan0
default via 192.168.2.1 dev wlan0
192.168.2.0/24 dev wlan0 scope link
And also changed sysctl "net.ipv4.conf.all.rp_filter=0"
and sysctl -w "net.ipv4.ip_forward=1"
. (Don't really think that ip_forward
is needed but I've changed it just in case).
Now, the weird thing is that when I ping Google forcing interface wlan0
it says Destination Host Unreachable
. The other interface works fine.
ping -I wlan0 google.es
PING google.es (173.194.45.183) from 192.168.2.21 wlan0: 56(84) bytes of data.
From 192.168.2.21 icmp_seq=1 Destination Host Unreachable
From 192.168.2.21 icmp_seq=2 Destination Host Unreachable
From 192.168.2.21 icmp_seq=3 Destination Host Unreachable
From 192.168.2.21 icmp_seq=4 Destination Host Unreachable
ping -I eth0 google.es
PING google.es (173.194.45.191) from 192.168.1.7 eth0: 56(84) bytes of data.
64 bytes from mad06s09-in-f31.1e100.net (173.194.45.191): icmp_seq=1 ttl=56 time=21.5 ms
64 bytes from mad06s09-in-f31.1e100.net (173.194.45.191): icmp_seq=2 ttl=55 time=21.7 ms
64 bytes from mad06s09-in-f31.1e100.net (173.194.45.191): icmp_seq=3 ttl=56 time=24.6 ms
64 bytes from mad06s09-in-f31.1e100.net (173.194.45.191): icmp_seq=4 ttl=55 time=31.1 ms