Linux supports the concept of “network aliases”; a NIC with more than one IP-address.
Previously, with networking managed by /etc/init.d/network, you would create a configuration file (/etc/sysconfig/network-scripts/ifcfg-eth0:0) holding the IP-address information for alias “0” of network interface “eth0“.
With NetworkManager, things become more complicated for non-trivial network configurations. The primary interface settings are in /etc/sysconfig/network-scripts/ifcfg-eth0 as usual:
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:04:23:C0:FF:EE
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-deadbeefc0ffee
Based on a comment by Cristiano (gone), I added a script to NetworkManager that would take care of configuring any network aliases that might be defined:
$ cat /etc/NetworkManager/dispatcher.d/00-aliases
#!/bin/bash
# Based on comment by Cristiano, http://mihai.ibanescu.net/networkmanager-and-virtual-interfaces
iface="$1"
shift
action="$1"
shift
if [ "$action" = "up" ]; then
for ALIAS in /etc/sysconfig/network-scripts/ifcfg-$iface:*; do
ALIAS=`echo $ALIAS | cut -d: -f 2`
/sbin/ifup $iface:$ALIAS
done
fi
# EOF
Note: This script needs to be executable.
The alias settings are configured in /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE="eth0:0"
NM_CONTROLLED="no"
BOOTPROTO=static
IPADDR=172.16.0.1
NETMASK=255.255.0.0
The essential ingredient here is “NM_CONTROLLED=no” (thanks to IRC @so_solid_moo, #fedora). Without that setting, NetworkManager will treat your alias as a real device and mess up your network accordingly ;-)