I have an IP address in my linux box 1.2.3.4 that is eth0:1. Alias of eth0. I want to create a route from that IP to an external 5.6.7.8 IP in another box.
How can I do it? Do I need netmask and gateway?
I have an IP address in my linux box 1.2.3.4 that is eth0:1. Alias of eth0. I want to create a route from that IP to an external 5.6.7.8 IP in another box.
How can I do it? Do I need netmask and gateway?
Routes in IP networking are always target oriented. There is an option to do source routing, but it is hardly ever used nowadays.
Simply define a new static route (using the route add -net
command), and define the metric for that route. The problem now is that unless your linux box is a router for 5.6.7.8 (i.e. all traffic for 5.6.7.8 must pass through this linux box), then traffic will simply go directly there, and your route won't have any effect. In order to make sure your traffic does go through 1.2.3.4, you must then set up a route on your source machine that makes 1.2.3.4 the router. You can do this with
route add -host 5.6.7.8 gw 1.2.3.4 mss <size>