Re: Two interfaces
- From: Pascal Hambourg <boite-a-spam@xxxxxxxxxxxxxxx>
- Date: Mon, 27 Oct 2008 15:59:16 +0100
Jozza a écrit :
i just added a static route:
ip route add 10.22.0.0/16 via 10.58.0.1 dev eth0
This route covers only 10.22.0.0/16, not 10.0.0.0/8. But if it is what you need, it is fine.
How does the router know that when a packet is sent to 10.22.xx.xx it should set the source ip to 10.58.16.28? Which it clearly does when i ping 10.22.xx.xx. Is it because it figures out that i want to use the gateway that is already set for a specific interface?
First it looks whether the route covering the destination contains an explicit source address. "ip route" will show which routes contain an explicit source address. If not, if the route contains a gateway then it looks for a source address in the route to the gateway. If not, it uses an address of the output interface. If the interface has no address, then it uses a suitable address of another interface.
In your case the route to 10.22.0.0/16 has a gateway, 10.58.0.1, and it is likely that the route to 10.58.0.0/16 containing this address has the source address 10.58.16.28.
In that case, it shouldn't be required to add the dev eth0 to the above route, right?
Indeed "dev eth0" should not be required and will be added automatically, because the system already knows that the gateway address is reachable on eth0.
.
- Follow-Ups:
- Re: Two interfaces
- From: Jozza
- Re: Two interfaces
- References:
- Two interfaces
- From: Jozza
- Re: Two interfaces
- From: Pascal Hambourg
- Re: Two interfaces
- From: Jozza
- Two interfaces
- Prev by Date: Two adapters, routing problems
- Next by Date: Re: Two adapters, routing problems
- Previous by thread: Re: Two interfaces
- Next by thread: Re: Two interfaces
- Index(es):
Relevant Pages
|