Monday, July 08, 2013

Re-Detect Network Interface Card in Ubuntu 13.04 and Centos 6.4

After making changes to the Network Interface Card (NIC), and when you run the command ifconfig, network adapters can't up. No visible interface ethernet (eth. ..), only the loopback interface (lo) is visible.

In ubuntu
If using the command "service networking restart", not seen the error. Use the command "ifup eth0", then you will get the error.
Ifup eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Cannot find device "eth0"
Error getting hardware address for "eth0": No such device
Failed to bring up ngeri-eth.


In centos
Service network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.                                                           [FAILED]

How to fix.
in Ubuntu 13.04
The operating system automatically detects the new hardware. In this case, the new network interface card (NIC) according the mac address. Look at file /etc/udev/rules.d/70-persistent-net.rules
vim  /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x1022:/sys/devices/pci0000:00/0000:00:03.0 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:01:55:03:59:44", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:/sys/devices/pci0000:00/0000:00:03.0 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e7:55:de", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

The new network interface adapter apparently is eth1 (NAME = "eth1"). NAME = "eth1" in the file /etc/udev/rules.d/cat 70-persistent-net.rules, is to reconfigure the file /etc/network/interfaces. NAME = "eth1" should be the same as in /etc/network/interfaces.

vim /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface.
#Eth1 according name="eth1" in /etc/udev/rules.d/cat 70-persistent-net.rules
auto eth1
iface eth1 inet dhcp
save and reboot

in Centos
Same as Ubuntu, in Centos look at /etc/udev/rules.d/70-persistent-net.rules. Then, there are a little different. Look at /etc/sysconfig/network-script/. Change the file ifcfg-eth0 to ifcfg-eth1. And edit the content of the file. Change device according the correct network adapter device, and comment or remove the mac address.
cd  /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth1
vim ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=094d6b99-b48e-45ac-b3d8-edc06b49c3aa
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
#HWADDR=08:00:27:c5:d1:42
USERCTL=no
IPV6INIT=no
PEERDNS=yes
save and reboot

Check your network adapter with command ifconfig eth1.It should be like this below,
Ifconfig eth1
Eth1      Link encap:Ethernet  HWaddr 08:00:27:e7:55:de
          inet addr:10.1.1.236  Bcast:10.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee7:55de/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:23407 (23.4 KB)  TX bytes:12358 (12.3 KB)
          Interrupt:19 Base address:0xd020

Change the name of ethernet (network interface card) with unique name
How if you want to change eth1 to a unique name, for example ngeri-eth. Go to file /etc/udev/rules.d/70-persistent-net.rules. Edit the file, and change NAME of the correct interface. Look at example below.

vim  /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 0x1022:/sys/devices/pci0000:00/0000:00:03.0 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:01:55:03:59:44", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:/sys/devices/pci0000:00/0000:00:03.0 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e7:55:de", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ngeri-eth"

And then edit the configuration network interface card.

In Ubuntu
Edit file /etc/network/interfaces
vim  /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
           
# The loopback network interface
auto lo
iface lo inet loopback
           
# The primary network interface
auto ngeri-eth
iface ngeri-eth inet dhcp
save and reboot

In centos
cd  /etc/sysconfig/network-scripts
cp ifcfg-eth1 ifcfg-ngeri-eth
vim ifcfg-ngeri-eth
DEVICE=eth1
TYPE=Ethernet
UUID=094d6b99-b48e-45ac-b3d8-edc06b49c3aa
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
#HWADDR=08:00:27:c5:d1:42
USERCTL=no
IPV6INIT=no
PEERDNS=yes
save and reboot

Chek the interface network, with command "ifconfig". Then the result should be like this.
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:65536  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)

ngeri-eth Link encap:Ethernet  HWaddr 08:00:27:e7:55:de
          inet addr:10.1.1.236  Bcast:10.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee7:55de/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1794 errors:11 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:124528 (124.5 KB)  TX bytes:14140 (14.1 KB)
          Interrupt:19 Base address:0xd020

Note: If you delete the file /etc/udev/rules.d/70-persistent-net.rules, and then restart. After restart, the file /etc/udev/rules.d/70-persistent-net.rules, automatically re-created. If there are a lot of network interface card that are detected then a few lines of configuration will be created in /etc/udev/rules.d/70-persistent-net.rule file. And the NAME of interface ethernet is sequential, starting from eth0, eth1 and so on.

2 comments:

  1. Quantum Binary Signals

    Get professional trading signals sent to your mobile phone every day.

    Start following our signals right now & profit up to 270% a day.

    ReplyDelete