IP aliasing is the process of assigning more than one IP address to a network interface. This is useful for Apache web server virtual hosting or other network servers such as ftp server.
This tutorial explains how to assign one or more IP address to a single network interface under FreeBSD operating system.
It is possible to create network alias or assign 2 ip address to a single NIC under FreeBSD operating system.
Our Sample Setup
- Interface name: lnc0 – IP : 192.168.1.1/255.255.255.0
- Interface name: lnc0 alias - IP : 192.168.1.5/255.255.255.255
Netmask must be different otherwise you will get an error ifconfig: ioctl (SIOCAIFADDR): File exists.
Set ip alias using ifconfig command line utility
Login as the root user.
Now, use ifconfig command as follows to set alias:
# ifconfig lnc0 192.168.1.5 netmask 255.255.255.255 alias
Persistent IP Alias Configuration
Edit file /etc/rc.conf to setup persistent ip aliasing option by appending following configuration, so that next time FreeBSD comes up (after restart/shutdown) it will create alias for you:
ifconfig_lnc0_alias0="192.168.1.5 netmask 255.255.255.255"
Finally, Restart FreeBSD network service using network restart script:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
More information about this here: http://www.cyberciti.biz/tips/freebsd-how-to-setup-2-ip-address-on-one-nic.html