Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Please explain in more detail what it is you want to achieve by this. –  wolfgangsz Jun 22 '11 at 15:17
    
I want to create a route between two IP addresses and set a discrete MTU value for that route. –  cateof Jun 22 '11 at 15:21
add comment

1 Answer 1

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>
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.