Re: ICMP Router Discovery
Re: ICMP Router Discovery
- Subject: Re: ICMP Router Discovery
- From: Andrew White <email@hidden>
- Date: Wed, 29 Jun 2005 11:33:18 +1000
Chase wrote:
the goal is simply to get a router address for a given interface.
i have a list of interfaces. some have ip addresses. some don't. for
those that do, i need the gateway address that they are connected to.
For an ethernet interface, this isn't a meaningful concept. An ethernet
interface address belongs to a subnet, and theoretically has direct access
to any other address on that subnet.
For example:
-----
% ifconfig -au inet
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 172.16.1.250 netmask 0xffffff00 broadcast 172.16.1.255
ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1444
inet 10.96.97.98 --> 10.96.97.97 netmask 0xff000000
-----
en0 is a normal ethernet address. It can directly send packets to any
address in the range 172.16.1.1 to 172.16.1.254, as well as to all
addresses in that range (172.16.1.255).
ppp0 is a tunnel, so it has a specified endpoint and its own set of rules
(BTW - the ppp0 addresses are faked).
-----
% netstat -rn -f inet
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 172.16.1.1 UGSc 9 7 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 9 87249 lo0
10.96.1.2 172.16.1.1 UGHS 1326 1417 en0
10.96.97/24 10.96.97.97 UGSc 1 0 ppp0
10.96.121/24 10.96.97.97 UGSc 2 6 ppp0
10.96.97.97 10.96.97.98 UH 5 0 ppp0
169.254 link#4 UCS 0 0 en0
172.16.1/24 link#4 UCS 1 0 en0
172.16.1.1 0:e0:29:73:8a:2d UHLW 11 0 en0 657
172.16.1.250 127.0.0.1 UHS 0 0 lo0
-----
This is the list of "gateways" my machine knows about. 172.16.1.1 is the
inside interface of my home router, discovered via DHCP. 10.96.97.97 is
the other end of my ppp VPN link, discovered via the ppp setup program and
passed down from 10.96.1.2 (my VPN access point).
It's entirely possible that there are other routers on the 172.16.1/24
subnet, but there's no way I'd know that unless someone or something told
me that they were willing to forward my packets to a specific address.
That is the general definition of a router - a device with more than 1
interface that is willing to pass (forward) packets across its interfaces.
In IPv4 land, a non-router (a 'host') is usually associated with one router
and passes all its packets to that router (the default gateway) unless it
is explicitly told to send them somewhere else (such as an on-link device
or an explicit rule for a particular address range). Between themselves,
the routers often run a protocol (such as RIP) to pass information about
who has direct access to which subnets - this allows them to make "next
hop" routing decisions. But nothing forces a router to participate in such
a protocol, or even admit to outside devices that it will forward packets.
IPv6 does have the concept of routers that advertise their presence. The
message basically says "I am a router, this is your subnet, this is my
address, I'm willing to be your default gateway". Even so, nothing stops a
machine deciding to forward packets (be a router) without advertising the fact.
Though perhaps I've missed your point. There is no concept of an interface
being "connected to" a router. Rather, the routing table associates a
destination address with a gateway, and then the interface required to
reach that gateway. The table above shows 11 address ranges.
- Messages for 10.96.97/24, 10.96.121/24 and 10.97.97.97 go out ppp0.
- Messages for 127/8, 127.0.0.1 and 172.16.1.250 go "out" lo0.
- Messages for 10.96.1.2, 169.254/16, 172.16.1/24, 172.16.1.1 and default
(ie "anything else") go out en0.
In each case, the "Gateway" entry gives the next-hop destination address of
the outgoing packet. If the destination is not the target address, then
the gateway is (hopefully) a router that can pass it on again.
You could reverse the description and say that the router 172.16.1.1 is
associated with en0 and 10.96.97.97 is associated with ppp0, but the
interface doesn't own the router (or vice-versa). Rather, the router just
happens to be next-hop accessible on that interface.
--
Andrew White
--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden