I have this /etc/network/interfaces (IPs on eth1 are fake)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.0.2.15
netmask 255.255.255.0
broadcast 10.0.2.255
gateway 10.0.2.2
auto eth1
iface eth1 inet static
address 123.123.123.45
netmask 255.255.255.0
broadcast 123.123.123.255
gateway 123.123.123.1
I use eth0 to connect to the internet while on eth1 I configured a public IP to a web server.
The connection to internet works fine if i keep up only eth0 and to the other side the web server works fine too if i keep up only eth1. They work perfectly as intended.
The problem is that I want both networks on at the same time and use exclusively eth0 to surf the internet / download updates and so on and I want to route all the traffic incoming to 123.123.123.45 to just that network.
How can I do that? I searched many tutorials but can't find a working solution or maybe I am doing something wrong. I do not want to reroute traffic from one interface to another, I would like to keep them separate and reroute traffic based on what IP they are coming from.
Is this possible?
I already tried
route add -host 123.123.123.45 dev eth1
Thank you in advance.