Senin, 10 Juni 2013

How to Add Network Adapter Without Reboot on CentOS 6/RHEL 6

This post describes on how to assign more than one network interface on the VMware virtual machine (VM) without reboot on linux. By default, one network interface should be enough to run the virtual over the network. In order to load balance the traffic or to enable multiple network segment in the VM, more than one interface card may required. It was assumed that eth0 hsa been configured and running. The process of adding a network interface card is very simple. In VMware ESXi/ESX and VMware workstation, you have to perform add hardware wizard and then select “Network Adapter”. This steps has been tested on CentOS 6.4.
1. Check existing network setting.
[root@centos64 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:735 errors:0 dropped:0 overruns:0 frame:0
          TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:72242 (70.5 KiB)  TX bytes:8635 (8.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
2. Enter network configuration folder, and look for ethx file. By default, first network interface will start with eth0. Next added network adapter will be eth1.
[root@centos64 ~]# cd /etc/sysconfig/network-scripts/
[root@centos64 network-scripts]# ls
ifcfg-eth0   ifdown-ippp  ifdown-routes  ifup-bnep  ifup-plip    ifup-sit          network-functions
ifcfg-lo     ifdown-ipv6  ifdown-sit     ifup-eth   ifup-plusb   ifup-tunnel       network-functions-ipv6
ifdown       ifdown-isdn  ifdown-tunnel  ifup-ippp  ifup-post    ifup-wireless
ifdown-bnep  ifdown-post  ifup           ifup-ipv6  ifup-ppp     init.ipv6-global
ifdown-eth   ifdown-ppp   ifup-aliases   ifup-isdn  ifup-routes  net.hotplug
3. After you add secondary network interface from VMware level, the file will automatically added the mac address in /etc/udev/rules.d/70-persistent-net.rules. Please take note on the mac address for eth1.
[root@centos64 ~]# more /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:f0", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:fa", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth1"
4. Now you need to create the configuration file for your new interface. The network interface configuration files are placed in /etc/sysconfig/network-scripts/. change the mac address according based on /etc/udev/rules.d/70-persistent-net.rules.
[root@centos64 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Add below setting :
DEVICE=eth1
HWADDR=00:0c:29:f1:24:fa
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.2.63
NETMASK=255.255.0.0
5. Based on the type interface being added, issue an ifup command. In this case, we have added eth1.
[root@centos64 ~]# ifup eth1
6. Verify new Network interfaces :
[root@centos64 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6949 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:804606 (785.7 KiB)  TX bytes:694075 (677.8 KiB)

[root@centos64 ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:FA
          inet addr:192.168.2.63  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24fa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:450 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40087 (39.1 KiB)  TX bytes:1182 (1.1 KiB)

Tidak ada komentar:

Posting Komentar