Thursday, August 2, 2012

Red Hat Enterprise Linux 6.x / Fedora 17 : Sample Network Configuration With Bonding And Persistent Device Names

This is a sample network interface configuration on Red Hat Enterprise Linux or Fedora Linux with persistent device names across reboots. We are not using Network Manager and all configuration is done manually and statically by editing configuration files. Server is connected to a public network via eth0-public interface, to a private LAN via eth1-private interface and to a iSCSI network via bond0-iscsi interface which is using eth2-iscsi and eth3-iscsi physical interfaces.


                      [public-net]
                            |
                         [eth0]-192.168.122.190/24
                            |
                   [RHEL/Fedora Server]
                     |        |    |
192.168.100.130/24-[eth1]  [eth2][eth3] 
                     |        |    |
                     |        [bond0]-172.16.0.130/16
                    |           |
    |           |
              [private-lan]  [iscsi-net]


[root@rhel6srv ~]# service NetworkManager stop
[root@rhel6srv ~]# chkconfig NetworkManager off
[root@rhel6srv ~]# yum remove NetworkManager


[root@rhel6srv ~]# vim /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:df:6a:25", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0-public"
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:30:94:49", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1-private"
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:dd:6b:96", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2-iscsi"
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:ef:76:d9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3-iscsi"

[root@rhel6srv ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0-public
DEVICE="eth0-public"
NAME="eth0-public"
BOOTPROTO="none"
HWADDR="52:54:00:DF:6A:25"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="fcc027ea-a7a8-4bb4-85b2-2f707a0d706a"
IPADDR="192.168.122.190"
NETMASK="255.255.255.0"


[root@rhel6srv ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1-private
DEVICE="eth1-private"
NAME="eth1-private"
BOOTPROTO="none"
HWADDR="52:54:00:30:94:49"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="657cedfe-c86d-4402-9987-942a253ea0a5"
IPADDR="192.168.100.130"
NETMASK="255.255.255.0"


[root@rhel6srv ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2-iscsi
DEVICE="eth2-iscsi"
NAME="eth2-iscsi"
BOOTPROTO="none"
HWADDR="52:54:00:DD:6B:96"
NM_CONTROLLED="no"
ONBOOT="no"
TYPE="Ethernet"
UUID="039001ef-2fd5-461e-9689-ef9d88c64ddc"
MASTER="bond0-iscsi"
SLAVE="yes"


[root@rhel6srv ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth3-iscsi
DEVICE="eth3-iscsi"
NAME="eth3-iscsi"
BOOTPROTO="none"
HWADDR="52:54:00:EF:76:D9"
NM_CONTROLLED="no"
ONBOOT="no"
TYPE="Ethernet"
UUID="05392749-3641-4e19-8c57-68526f8d985d"
MASTER="bond0-iscsi"
SLAVE="yes"


[root@rhel6srv ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0-iscsi
DEVICE="bond0-iscsi"
NAME="bond0-iscsi"
MASTER="yes"
BOOTPROTO="none"
IPADDR="172.16.0.130"
NETMASK="255.255.0.0"
ONBOOT="yes"
BONDING_OPTS="mode=0 miimon=100"


[root@rhel6srv ~]# vim /etc/modprobe.d/bond0-iscsi.conf 

alias bond0-iscsi bonding


[root@rhel6srv ~]# ip addr show | grep "state UP" | awk '{print $2}' | cut -d ":" -f1
eth0-public
eth1-private
eth2-iscsi
eth3-iscsi
bond0-iscsi

[root@rhel6srv ~]# cat /proc/net/bonding/bond0-iscsi 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode:
load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface:
eth1-iscsi
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:b0:33:e7
Slave queue ID: 0

Slave Interface:
eth2-iscsi
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:70:1f:8f
Slave queue ID: 0