IP Aliasing

Mel fbsd.questions at rachie.is-a-geek.net
Thu Feb 21 12:33:38 UTC 2008


On Thursday 21 February 2008 13:07:08 Siraj Shaikh wrote:

> ifconfig_ed0_alias0="inet 127.0.0.251 netmask 0xffffffff"
> ifconfig_ed0_alias1="inet 127.0.0.252 netmask 0xffffffff"
> ifconfig_ed0_alias2="inet 127.0.0.253 netmask 0xffffffff"
>
> Just want to know, as I want to configure about 253 addresses as an
> alias on a single machine (along with the primary address, this will
> be 254 address, a whole C-class subnet) - and would like these entries
> to hold when I boot. Also, is there any shortcut to adding a range of
> net/host address or would I have to add a line for each address?

Yes and yes. Yes it needs one line per alias and yes, there's a shortcut:

for i in $(jot - 0 254); do
  echo ifconfig_ed0_alias${i}="\"inet 127.0.0.$((i+1)) netmask 0xffffffff\""
done >>/etc/rc.conf

Wouldn't do this with 127.0.0 btw, but I figured you wouldn't. You'd also have 
to make a provision for the main IP, but then again, it's easier to remove 
the specific line by hand.
-- 
Mel


More information about the freebsd-questions mailing list