Re: Two interfaces



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.
.



Relevant Pages

  • Re: Wireless laptop roaming through various access points
    ... Whichever interface has the default route pointing to it, ... It is possible to assign more than one default gateway in the ... What needs to change is the ARP table, which maps the MAC address to ...
    (alt.internet.wireless)
  • Re: Routing for Verizon FIOS -- Reward for answer
    ... The problem we have is this:  Verizon's gateway is 70.x.x.1. ... address for our router ...  What do we use as an address for the outside interface ... route outbound through the gateway. ...
    (comp.dcom.sys.cisco)
  • Re: ethernet routing
    ... interface but not the 10.20.4.48 interface. ... But you set the default gateway to 10.20.x.x which it can not get to. ... I ususally add a '-host' entry to the routing table. ... 'route add default gw 192.168.1.1' fixes the route on host1 then on the gateway1 machine: 'route add default gw 10.20.4.48' to help packets go to gateway2 if needed. ...
    (Debian-User)
  • Load Balancing with Multi-path Routes
    ... gateway by using multipath routes, however I'm stuck with some problems. ... I successfully defined the multipath route, ... 198.X.Y.0/24 dev eth0 proto kernel scope link src 198.X.Y.1 ...
    (comp.os.linux.networking)
  • Re: AW: Gateway question
    ... then is will be used if the lower cost route fails. ... AIX Certified Advanced Technical Expert ... Normally you have 1 default gateway ... When we configure the gateway on one interface, ...
    (AIX-L)