Date: Sat, 16 Nov 2002 16:21:34 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-questions@FreeBSD.ORG Subject: Re: question on IP alias/broadcast Message-ID: <20021116162134.GB12726@happy-idiot-talk.infracaninophi> In-Reply-To: <5.2.0.9.2.20021116082511.00b26508@molson.wixb.com> References: <058f01c28d76$22296230$020aa8c0@morpheous> <5.2.0.9.2.20021116082511.00b26508@molson.wixb.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Nov 16, 2002 at 08:28:32AM -0600, J.D. Bronson wrote: > I setup an alias statment in rc.conf and it seems to work fine.. > but I have a question on the broadcast IP: > > > em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 > options=3<rxcsum,txcsum> > inet 192.168.100.1 netmask 0xffffff00 broadcast 192.168.100.255 > inet 192.168.100.4 netmask 0xffffffff broadcast 192.168.100.4 > ether 00:a0:9d:23:0b:f6 > media: Ethernet autoselect (100baseTX <full-duplex>) > status: active > > > Why isnt the alias broadcast set to .255 ? Because the broadcast address is actually completely determined by the combination of the inet address and netmask. It's redundant information really. Remember that an IP number or netmask expressed as a dotted quad is really just a 32bit unsigned integer, and can be equally well expressed as a hexadecimal or even decimal integer. thus: 192.168.100.1 is the same as 0xc0a86401 or 3232261121 and 0xffffff00 is the same as 255.255.255.0 or 4294967040 Thus you can take an inet address and a netmask and bitwize logic to generate the network address: $network = $inet & $netmask; and from the network address and the netmask, you can generate the broadcast address: $broadcast = $network | ~$netmask; So your question really boils down to "why is the netmask 0xffffff00 for the first address and 0xffffffff for the alias address?" That's pretty much simply so that the kernel knows which source address it should put into outgoing packets when it isn't already determined. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021116162134.GB12726>