I have 3 interfaces in ubuntu machine. eth0/eth1/eth2.
- eth0 is management interface with ip (10.102.x.x)
- eth1 is private interface with ip 192.168.1.x
- eth2 is another private interface with ip 192.168.2.x
I want to reach to 25.25.25.x (which is the box in some other network). Here is the topology:-
Ubuntu machine <----------------> Router <------------> End Machine
192.168.1.x 192.168.1.x 25.25.25.x 25.25.25.x
I want to reach to 25.25.25.x using eth1 and eth2 interfaces. So for that i am trying to do source ip based routing tables. Here is the configuration applied:
ifconfig eth1 up
ifconfig eth1 192.168.1.x netmask 255.255.255.0
ip rule add from 192.168.1.x table 1
ip route add 192.168.1.0/24 dev eth1 scope link table 1
ip route add default via 192.168.1.x dev eth1 table 1
However this is not being successful as ping 25.25.25.x -I eth1 doesn't work. However the direct route works:
ifconfig eth1 up
ifconfig eth1 192.168.1.x netmask 255.255.255.0
route add -net 25.25.25.0/24 gw 192.168.1.x
In non-working case the linux client itself is doing broadcast for 25.25.25.x ip, which should't happen.
Here is the ip route and ip route show table 1 output:-
root@ubuntu:~# ip rule show
0: from all lookup local
32765: from 192.168.1.x lookup 1
32766: from all lookup main
32767: from all lookup default
root@ubuntu:~# ip route show table 1
default via 192.168.1.x dev eth1
192.168.1.0/24 dev eth1 scope link
Can someone please answer this as to why first case isn't working?
root@ubuntu:~# ip rule show
0: from all lookup local
32765: from 192.168.1.x lookup 1
32766: from all lookup main
32767: from all lookup default
i am posting the ip route show table 1 output:-
root@ubuntu:~# ip rule show
0: from all lookup local
32765: from 192.168.1.x lookup 1
32766: from all lookup main
32767: from all lookup default
root@ubuntu:~# ip route show table 1
default via 192.168.1.x dev eth1
192.168.1.0/24 dev eth1 scope link
– Ashutosh Shukla Nov 05 '18 at 06:17