My problem is the following. (kubuntu 14.04 64bits, kernel 4.40)
I have a remote computer (on another place, I can't go on site) that have two network cards.
On the second card (eth1
), I have a dhcp client which serve the IP 192.168.0.189/24
. Through this IP, I can connect with Teamviewer or anydesk.
On the first card (eth0
), the IP is set to 192.168.2.10/24
. All works well.
But I have a device IP that IP is 192.168.0.100/24
and must be connected on eth0
(note that 192.168.0.100/24
is free on eth1
).
So I add the IP 192.168.0.110/24
to eth0
to access this new device.
The problem is, in that case, we cannot initiate new connection on Teamviewer or anydesk.
So, I'm looking to explain my system that it must use
eth0
to access192.168.0.100
eth1
to all other192.168.0.x
I think that route
could be what I want, but I don't want to test it right now, because on error, things will be terrible to debug.
My question is:
Will the command route add 192.168.0.100/24 eth0
be enough?
Should I generate some script for the other 192.168.0.x
addresses?
#ip a before ip addr add 192.168.0.110/24 dev eth0
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.2.10/24 brd 192.168.2.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether yy:yy:yy:yy:yy:yy brd ff:ff:ff:ff:ff:ff
inet 192.168.0.189/24 brd 192.168.0.255 scope global noprefixroute eth1
valid_lft 401100sec preferred_lft forever
#ip a after ip addr add 192.168.0.110/24 dev eth0
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.2.10/24 brd 192.168.2.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 192.168.0.110/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether yy:yy:yy:yy:yy:yy brd ff:ff:ff:ff:ff:ff
inet 192.168.0.189/24 brd 192.168.0.255 scope global noprefixroute eth1
valid_lft 401100sec preferred_lft forever