How do I add another IP to my BSD machine?

This information is directly out of the FreeBSD Handbook,
in Chapter 11 titled “Configuration and Tuning”. 



To add multiple
IP addresses to your BSD machine, you will have to edit your
rc.conf.  Find the line for your already existing network card,
which may look like the following:



ifconfig_fxp0=”inet 10.0.0.1 netmask 255.255.255.0”


After
this line, you will need to add your IP aliases. Note that alias
entries MUST start with alias0 and increment from there(alias0, alias1,
aslias2, etc.). The configuration
will stop at the first missing number.


The calculation of alias netmasks is important, but fortunately quite simple. For a
given interface, there must be one address which correctly represents the network’s
netmask. Any other addresses which fall within this network must have a netmask of all
1s (expressed as either 255.255.255.255 or 0xffffffff).



For example, your rc.conf may look similar to the following after you have added your ips:


ifconfig_fxp0=”inet 10.0.0.1 netmask 255.255.255.0”


ifconfig_fxp0_alias0=”inet 10.0.0.2 netmask 255.255.255.255”



ifconfig_fxp0_alias1=”inet 10.0.0.3 netmask 255.255.255.255”



ifconfig_fxp0_alias2=”inet 10.0.0.4 netmask 255.255.255.255”



ifconfig_fxp0_alias3=”inet 10.0.0.5 netmask 255.255.255.255”



Please
note that CPanel has been known to add addresses incorrectly.  It
is recommended that you add your virtual ips manually.

Your rating: None