Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jan 2000 11:42:32 +0100
From:      "ROGIER MULHUIJZEN" <MULHUIJZEN@PZH.NL>
To:        <freebsd-stable@freebsd.org>, <mylists@inr.net>
Subject:   Re: Multiple IP addresses
Message-ID:  <s88c3ac3.012@smtp.pzh.nl>

next in thread | raw e-mail | index | archive | help
>Just a couple of questions concerning multiple IP's.   In searching
through
>the archives I've seen references to binding the addresses to the NIC
as
>well as the loopback, which is the proper method?

You might be able to bind an IP address to more than one interface, but
if neither is loopback, I'm not sure if it would work. I wouldn't even
know why you would want that because both sides would have to be on the
same subnet, and thus on the same physical network (unless the machine
in question is a bridge....)

I at least got a message from my kernel that the IFA (I'm guessing
interface address) changed... so I'm going out on a limb here saying
that it wouldn't work.

Now if one of the two interfaces is loopback (lo0) any traffic from the
localhost to the IP is routed through lo0 anyways so why even bind it to
your loopback? (ping a machines own IP and look at the 'netstat -rn'
output)

>The scenario I have setup is as follows, the server (xl0) has been
assigned
>the IP address of yyy.yyy.yyy.8 and the I route an entire Class C to
that
>interface in the router, e.g.
>ip route xxx.xxx.xxx.0 255.255.255.0 yyy.yyy.yyy.8

>To recap, my questions are, which interface should be used to bind the
ip's
>to and is it acceptable to bind .0 and .255 to the interface although
by
>convention they shouldn't be used for anything.

You have a machine which you want to respond to every single IP in a
class C subnet. So you bind every single IP to the NIC interface...

/sbin/ifconfig xl0 inet 198.77.215.1 netmask 0xffffff00 alias
/sbin/ifconfig xl0 inet 198.77.215.2 netmask 0xffffffff alias
/sbin/ifconfig xl0 inet 198.77.215.3 netmask 0xffffffff alias
 ... through to ...
/sbin/ifconfig xl0 inet 198.77.215.253 netmask 0xffffffff alias
/sbin/ifconfig xl0 inet 198.77.215.254 netmask 0xffffffff alias

Now you could bind them all to lo0, but why would you want to? Every
single one of those IP's will get a route through lo0 as soon as you use
them from localhost. 

But a better way might be to give one of the IP addresses to the router
and let it do the routing for you. This will save you a whole hop, and
might make things just a tad easier for your machine to run. Also if you
ever want to offload a few of the IPs to other machines on the same
ethernet segment you would have to switch all of the other IPs from lo0
to xl0 anyways.

>I then added an entry in /etc/rc.local to run the following shell
script:

>#!/bin/sh

>/sbin/ifconfig lo0 xxx.xxx.xxx.0 netmask 0xffffff00 alias
>/sbin/ifconfig lo0 xxx.xxx.xxx.1 netmask 0xffffffff alias
>/sbin/ifconfig lo0 xxx.xxx>xxx.2 netmask 0xffffffff alias

>through

>/sbin/ifconfig lo0 198.77.215.255 netmask 0xffffffff alias

>According to the feedback I recently received from Eric Futch
><efutch@nyct.net>, who was kind enough to respond privately to clarify
his
>recent post, this (same) script if named /etc/start_if.lo0 will be
run
>auto-magically on boot by rc.network.

Or use the following syntax in rc.conf

network_interfaces="lo0 xl0"
ifconfig_lo0="inet 127.0.0.1"
ifconfig_xl0="inet yyy.yyy.yyy.8 netmask 0xffffff00"
ifconfig_xl0_alias0="inet xxx.xxx.xxx.1 netmask 0xffffff00"
ifconfig_xl0_alias1="inet xxx.xxx.xxx.2 netmask 0xffffffff"
ifconfig_xl0_alias2="inet xxx.xxx.xxx.3 netmask 0xffffffff"
....through to....
ifconfig_xl0_alias252="inet xxx.xxx.xxx.253 netmask 0xffffffff"
ifconfig_xl0_alias253="inet xxx.xxx.xxx.254 netmask 0xffffffff"

Now on the use of xxx.xxx.xxx.0 and xxx.xxx.xxx.255 in a class C
subnet.

xxx.xxx.xxx.255 is a definate NO NO. in a class C subnet it's the
broadcast address, believe me when I tell you you will get all sorts of
trouble when you use it as an IP. Every single IP with netmask
0xffffff00 on the same subnet will respond to it (in your case only
xxx.xxx.xxx.1 but that might change). Things get messy.

Now xxx.xxx.xxx.0 is a different story. It's the subnet identifier.
Some OSs accept it as a valid IP, others don't. I'm not up to speed on
what the exact definition is for it, but "It's a good idea" (tm) not to
use it.

Also, xxx.xxx.xxx.1 is by convention the default gateway for a subnet.
It's one of the things that you are free in whether to use it or not,
but it's common to do so.

I hope this answers your questions, and that I haven't bungled anything
in my reply (but I'm sure someone will point out any mistakes I
made...). 

              DocWilco



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?s88c3ac3.012>