How to add new Network Adapter in Hyper-V Linux CentOS 6.4

This is the blog, how to add new network interface in Hyper - V Centos 6.4 Virtual Machine.


For a System Administrator, It is a common task which is required on demand to add additional Network Interface. It may be required for different purpose i.e. Setup Bridge Interface, Setting up VLAN etc.

1 - Requirement :-In my scenario, I am using Centos release 6.4 (Final) Virtual Machine running on Hyper -V.


2 - Check Current Interfaces :-

We can check current available Network interfaces using below method.

A- Using command ifconfig -a

[root@testsvn ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:15:5D:01:6B:00
inet addr:10.0.0.88 Bcast:10.0.1.255 Mask:255.255.254.0
inet6 addr: fe80::215:5dff:fe01:6b00/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8710 errors:0 dropped:0 overruns:0 frame:0
TX packets:345 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1049224 (1.0 MiB) TX bytes:53714 (52.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:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:800 (800.0 b) TX bytes:800 (800.0 b)


B- Using command ip link

[root@testsvn ~]# ip link
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2:
eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:15:5d:01:6b:00 brd ff:ff:ff:ff:ff:ff

[root@testsvn ~]#


3- Now Add new network interface from Hyper - V Console VM Setting.

- Shutdown your VM first

Right Click on (1) VM Go to VM (2) setting  









- Select (1) Add Hardware from left Action Menu, Choose (2) Network Adapter in the Hardware menu list, Click on (3) Add button



















Now (1) New network adapter will be displayed in left side menu, Select (2) required Virtual Switch, (3) Apply and (4) OK.


































Start Virtual Machine after applied above setting.
 
4- Check newly added interface :- 

[root@testsvn ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:15:5D:01:6B:00
inet addr:10.0.0.88 Bcast:10.0.1.255 Mask:255.255.254.0
inet6 addr: fe80::215:5dff:fe01:6b00/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4330 errors:0 dropped:0 overruns:0 frame:0
TX packets:269 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:489297 (477.8 KiB) TX bytes:43043 (42.0 KiB)

eth1 Link encap:Ethernet HWaddr 00:15:5D:01:6B:04
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:3672 errors:0 dropped:0 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:406333 (396.8 KiB) TX bytes:1898 (1.8 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:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:300 (300.0 b) TX bytes:300 (300.0 b)



Newly available interface is eth1


5- Let's configure eth1 interface and activate this adapter:-

please make a note eth1 interface MAC address, in above example you can see MAC ID 00:15:5D:01:6B:04

Now create a file ifcfg-eth1 under this path :/etc/sysconfig/network-scripts/ifcfg-eth1

and append below line

[root@testsvn ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=00:15:5D:01:6B:04
TYPE=Ethernet
UUID=d506b5c8-bc15-477e-9575-d6190f8304c7
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp


Save and Exit from File.


6- Restart Networking service to apply changes :


[root@testsvn ~]# service network restart


7- Let's check for IP address :-

Use command ifconfig or ip addr to check assigned IP address.

[root@testsvn ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:5D:01:6B:00
inet addr:10.0.0.88 Bcast:10.0.1.255 Mask:255.255.254.0
inet6 addr: fe80::215:5dff:fe01:6b00/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37772 errors:0 dropped:0 overruns:0 frame:0
TX packets:435 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4249694 (4.0 MiB) TX bytes:80131 (78.2 KiB)

eth1 Link encap:Ethernet HWaddr 00:15:5D:01:6B:04
inet addr:10.0.0.127 Bcast:10.0.1.255 Mask:255.255.254.0
inet6 addr: fe80::215:5dff:fe01:6b04/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5225 errors:0 dropped:0 overruns:0 frame:0
TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:580183 (566.5 KiB) TX bytes:2792 (2.7 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:38 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1900 (1.8 KiB) TX bytes:1900 (1.8 KiB)



We have successfully added newly Interface and getting IP address from DHCP Server.


That's All
!!!Cheers!!!