Home arrow Journal arrow Adding a Network Alias in FreeBDS
Adding a Network Alias in FreeBDS PDF
Tuesday, 15 October 2013
Here is a quick how to add a network alias in FreeBSD.

Let's say you have a network card called em0 and you've configured to have the IP: 10.0.0.100. The line in /etc/rc.conf file that configure that IP will be:

/etc/rc.conf
...

ifconfig_em0="inet 10.0.0.100 netmask 255.255.255.0"

...

We want to add an IP alias 192.168.0.100 to the same network card. In order to do our network config from /etc/rc.conf will look like this:

/etc/rc.conf
...

ifconfig_em0="inet 10.0.0.100 netmask 255.255.255.0"
ifconfig_em0_alias0="inet 192.168.0.100 netmask 255.255.255.0"

...

If you want to add more IPs from the same class (for example 192.168.0.101), you must use 255.255.255.255 netmask for all but first IP.

So our config file will be:

/etc/rc.conf
ifconfig_em0="inet 10.0.0.100 netmask 255.255.255.0"
ifconfig_em0_alias0="inet 192.168.0.100 netmask 255.255.255.0"
ifconfig_em0_alias1="inet 192.168.0.101 netmask 255.255.255.255"


There's also a newer and simpler way of adding aliases. In order to add and alias in FreeBSD use the following line to acomplish the same as previous:

/etc/rc.conf
...

ipv4_addrs_em0="10.0.0.100/24 192.168.0.100/24 192.168.0.101/32"

...


Last Updated ( Tuesday, 15 October 2013 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?