0

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?

Chadddada
  • 1,680
  • 1
  • 19
  • 26
cateof
  • 173
  • 1
  • 7

1 Answers1

0

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>
wolfgangsz
  • 8,847
  • 3
  • 30
  • 34
  • the box is not a router for 5.6.7.8. So I guess that I need to use route add -net 5.6.7.8 gw 1.2.3.4 mss 1500 (please note -net and not -host) – cateof Jun 22 '11 at 19:24