Quantcast
Channel: GoLinuxHub
Viewing all articles
Browse latest Browse all 392

How to detect new NIC/Ethernet card without rebooting in Linux

$
0
0
I have a Red Hat 6 vm created in my VMware Workstation Lab. I will just go ahead and add a new NIC card to my running RHEL machine.

Now let us try to detect it without rebooting the OS

If we check the output of ifconfig
# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B9:4D:D3
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb9:4dd3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:91992 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58283 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:99437002 (94.8 MiB)  TX bytes:5498693 (5.2 MiB)

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:2964 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2964 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:388592 (379.4 KiB)  TX bytes:388592 (379.4 KiB)

So as of now the new thernet card configuration is not reflected. There is a file /etc/udev/rules.d/70-persistent-net.rules which contains details about the connected ethernet card in your RHEL box.

I have discussed about the working of this file in the below link
device eth0 does not seem to be present, delaying initialization

In this file you can view the details of the newly connected Ethernet Card
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="
00:0c:29:b9:4d:d3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b9:4d:dd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

As you see it shows two ethernet card details i.e. eth0 and eth1. As of now eth0 is already in connected state as per the output of ifconfig which can also match using the MAC details. So let us manually create a new configuration file for the new card.
# cd /etc/sysconfig/network-scripts
To skip the hard work let us copy the contents from eth0 to our new file, in that way we will just have to make required changes
# cp ifcfg-eth0 ifcfg-eth1
Lines marked in blue are the one you need to change as per your environment
# vi ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
HWADDR=00:0c:29:b9:4d:dd
IPADDR=192.168.1.5
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8

DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"

Restart your network services
# service network restart
Shutting down interface eth0:                              
[  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Determining if ip address 192.168.1.11 is already in use for device eth0...
                                                           [  OK  ]
Bringing up interface eth1:  Determining if ip address 192.168.1.5 is already in use for device eth1...
                                                           [  OK  ]

Verify your results
# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B9:4D:D3
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb9:4dd3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:92368 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58550 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:99470396 (94.8 MiB)  TX bytes:5531059 (5.2 MiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:B9:4D:DD
          inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb9:4ddd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:372 (372.0 b)  TX bytes:636 (636.0 b)


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:2964 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2964 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:388592 (379.4 KiB)  TX bytes:388592 (379.4 KiB)

I hope that was helpful. Let me know your success and failures

Related Articles
Creating an internal network using VMware Workstation
How to do Ethernet/NIC bonding/teaming in Red Hat Linux
How to configure network in Red Hat Linux
Configure network in Solaris 10


Follow the below links for more tutorials

What is the difference/comparison between Unix and Linux ?
What are the maximum and minimum limits for RHEL 4 vs 5 vs 6 ?
Step by Step Linux Boot Process Explained In Detail
What is the difference between ext3 and ext4 filesystem in Linux ?
How to configure Private Network in VMware Workstation
9 examples to help you understand top command usage in Unix/Linux
Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
Understanding Load Average in Linux and when to be worried about it?
Disk Attachment Technology FC vs SAS vs iSCSI
Understanding UMASK value in Linux
How to keep a track of all the commands run by any user in Linux
How do you check Linux machine is Physical or Virtual remotely?


Viewing all articles
Browse latest Browse all 392

Trending Articles