Re: Why can't I sendto() to 127.255.255.255
- From: "Bruce M. Simpson" <bms@xxxxxxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 14:09:32 +0100
Abraham K. Mathen wrote:
Is it possible to successfully sendto() on a UDP socket
with 127.255.255.255 as the destination address? If yes,
how can that be done.
No, because in FreeBSD, lo(4) is not implemented as a broadcast interface. It is a multicast capable software loopback interface. It has no concept of a broadcast domain. Unicast traffic, as well as multicast traffic, is looped back on this interface.
You can see that in the output of 'ifconfig lo0', the BROADCAST flag is not set.
RFC 3330 says:
"A datagram sent by a higher level protocol to an address anywhere within this block should loop back inside the host."
A few quick tests suggests this does not happen by default on FreeBSD. I suspect that this is because although lo0 is configured with 127.0.0.1/8 by default, a cloning interface route is not added as ARP does not run on such an interface. Therefore only a host route for 127.0.0.1 appears in the table.
To tell the stack to transmit datagrams destined for 127/8 via lo0 you'd do the following:
route -n add 127.0.0.0/8 -net -iface lo0
Nothing will reply as nothing is listening on that address (127.255.255.255).
You can configure multiple lo interfaces, they just don't participate in a broadcast domain, as they are not broadcast interfaces. However, how lo(4) is implemented has the peculiar side-effect that all loopback interfaces are in the same 'transmission domain'... tcpdumping on lo0 will show you traffic on lo1. All loopback ifnet instances see each other's traffic, it's just up to the stack to reject it if it's not destined for a configured address on that instance.
To try that, you'd 'ifconfig lo1 create' and 'ifconfig lo1 127.0.0.2/32' as FreeBSD's network stack does not really allow you to have more than one interface configured on the same subnet.
Regards,
BMS
_______________________________________________
freebsd-net@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@xxxxxxxxxxx"
- References:
- Why can't I sendto() to 127.255.255.255
- From: Abraham K. Mathen
- Why can't I sendto() to 127.255.255.255
- Prev by Date: Re: Why can't I sendto() to 127.255.255.255
- Next by Date: Re: kern/108211: [netinet] potentially a bug for inet_aton in sys/netinet/libalias/alias_proxy.c
- Previous by thread: Re: Why can't I sendto() to 127.255.255.255
- Index(es):
Relevant Pages
- ipt_ROUTE loopback
... the local routing table and have traffic destined for one interface go ...
always has the destination MAC of the first interface when it reaches ... (Linux-Kernel) - Re: Priority of connection used to access Internet
... A packet's outgoing interface is determined by its destination and the cost
... of the destination specified by the entries in the routing table. ... (microsoft.public.windowsce.platbuilder) - Re: Addendum:
... "closest" to the destination (i.e the interface out of which the packet ...
a Cisco router will use as a source address the primary address of the ... interface
expected to be the interface used to reach the destination. ... (comp.dcom.sys.cisco) - Re: site to site vpn with internal NAT
... :interface. ... :192.168.1.101 tries to contact a peer on the remote
side, ... so the *destination* IP 192.168.49.x will be changed to the destination ...
and since there is a match, the packet will go out over the VPN. ... (comp.dcom.sys.cisco) - Re: rtentry and rtrequest
... an interface w/o IFF_BROADCAST, as it utilizes broadcasts. ... IFF_BROADCAST
just means that the interface has a broadcast address, ... jnet0: jnet_start_lockedcalled.
... (freebsd-net)