Creating a sub-interface in FreeBSD (adding a second IP to interface)
Configuring interface
To assign multiple network addresses to the same interface in FreeBSD_9.3/10.3, you must make the appropriate alias entries in the /etc/rc.conf configuration file. Before editing it is recommended to make a copy of this file:
root@freebsd-9:~# cp /etc/rc.conf /etc/rc.conf.backupNext, let's view active interfaces:
root@freebsd-9:~# ifconfig -uOur network interface is named em0 and so far it has one IP address assigned to it.
Alias for em0 looks like this:
ifconfig_em0_alias0="inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"Please note that the records of aliases must begin with alias0 and continue in a certain order (e.g. _alias1, _alias2, etc.).
The configuration process will stop at the first missing number. E.g. for adding additional IP address 83.166.X.138 with mask 255.255.240.0, the following entry must be added to the /etc/rc.conf file:
root@freebsd-9:~# vi /etc/rc.confStart interface
To apply the changes, you must restart FreeBSD network service and update the routing table. In order not to lose connection with the server via SSH, the following must be done:
root@freebsd-9:~# /etc/rc.d/netif restart && /etc/rc.d/routing restartLet's display active interfaces once again:
root@freebsd-9:~# ifconfig -uThe output of the ifconfig command shows that interface em0 has two IP addresses. This completes the configuration of the additional IP address.