Network Configuration and troubleshooting [Red Hat]

Don't be shellfish...twitter Network Configuration and troubleshooting [Red Hat]google Network Configuration and troubleshooting [Red Hat]linkedin Network Configuration and troubleshooting [Red Hat]stumbleupon Network Configuration and troubleshooting [Red Hat]email Network Configuration and troubleshooting [Red Hat]facebook Network Configuration and troubleshooting [Red Hat]

In this post I am going to talk about network configuration in Red Hat Linux based system (Red Hat, Fedora, CentOS).Red Hat logo 226 Network Configuration and troubleshooting [Red Hat]

Unlike Debian systems in which the network configuration of all interfaces is only in /etc/network/interfaces, in Red Hat system each interface has it own file.

Network Configuration

Every interface configuration file are stored in /etc/sysconfig/network-script/ifcfg-<name>. For example if you want to configure you eth0 you will need to edit the /etc/sysconfig/network-script/ifcfg-eth0. Here is an example of a configuration file of the network interface using:

  • DHCP
    root@sigmoun-redhat ~] vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes
    NM_CONTROLLED=no #Set it 'yes' if you want network-manager to manage this interface
  • static
    root@sigmoun-redhat ~] vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    BOOTPROTO=static
    PREFIX=24
    GATEWAY=192.168.1.1 # Change it according to your network
    DNS1=8.8.8.8
    DNS2=8.8.4.4
    ONBOOT=yes
    NM_CONTROLLED=no #Set it 'yes' if you want network-manager to manage this interface

To apply change no need to restart all the network service, you can only do

root@sigmoun-redhat ~] ifdown eth0
root@sigmoun-redhat ~] ifup eth0

and all the changes will be applied.
Of course if you want to configure your eth1 instead of eth0, edit /etc/sysconfig/network-scripts/ifcfg-eth1. If it’s your wifi interface it will be the wlan0 etc.

If you have some common configuration in all your interface no need to put it many time in each interface file. You can specify it in /etc/sysconfig/network. In addition to common configuration this file contain the hostname.

root@sigmoun-redhat ~] vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=sigmoun-redhat
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
ONBOOT=yes

Network Troubleshooting

meme computer Network Configuration and troubleshooting [Red Hat]

Ok… Now it’s time to check if your network configuration is working properly.

Check if your network interface has obtain an IP

Supposing you have configured your eth0 statically using this IP 192.168.1.100. Let’s see if your interface successfully take it.

root@sigmoun-redhat ~] ping 192.168.1.100
ping: sendmsg: Network is unreachable
--- 192.168.1.100 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Please make sure your network cable is plugged…
if it’s still persist, check that you eth0 have successfully take the IP you specified or simply if it has an IP. To do so, do the following.
If you have equivalent result with no IP displayed, it means that your interface has no IP so it’s not connected. Verify you ifcfg file and try ifup eth0 then ifdown eth0

root@sigmoun-redhat ~] ifconfig eth0
eth0      Link encap:Ethernet  HWaddr bc:5f:f4:8c:07:68  
          inet6 addr: fe80::be5f:f4ff:fe8c:768/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:582633 errors:0 dropped:15 overruns:0 frame:0
          TX packets:397974 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:663898168 (663.8 MB)  TX bytes:51508356 (51.5 MB)

When you fix the problem you should have :

root@sigmoun-redhat ~] ifconfig eth0
eth0      Link encap:Ethernet  HWaddr bc:5f:f4:8c:07:68  
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::be5f:f4ff:fe8c:768/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:582669 errors:0 dropped:15 overruns:0 frame:0
          TX packets:398021 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:663902946 (663.9 MB)  TX bytes:51522116 (51.5 MB)

So let’s try to ping our new IP:

root@sigmoun-redhat ~] ping 192.168.1.100
PING 192.168.1.160 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_req=1 ttl=64 time=0.032 ms
64 bytes from 192.168.1.100: icmp_req=2 ttl=64 time=0.024 ms
64 bytes from 192.168.1.100: icmp_req=3 ttl=64 time=0.027 ms
--- 192.168.1.160 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.024/0.027/0.032/0.006 ms

It works !

Check your GATEWAY

You will probably need to connect to the internet. So you will need to use the network gateway.
Let’s try our internet connectivity :

root@sigmoun-redhat ~] ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.1.100 icmp_seq=1 Destination Host Unreachable
From 192.168.1.100 icmp_seq=2 Destination Host Unreachable
From 192.168.1.100 icmp_seq=3 Destination Host Unreachable
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3017ms

At this point it seemes that you have problem with your GATEWAY.
Let’s run a traceroute to be sur…
If look at the following result, you will see that the packet has only passed through your network interface and didn’t find a gateway.

root@sigmoun-redhat ~] traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  sigmoun-redhat (192.168.1.100)  560.553 ms !H  560.545 ms !H  560.543 ms !H

So edit /etc/sysconfig/network-script/ifcfg-eth0 and check your gateway… you should have the following:

root@sigmoun-redhat ~] traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  3.097 ms  3.905 ms  4.524 ms
 2  * * * (* * *)  49.623 ms  49.924 ms  50.214 ms
 3  * * * (* * *)  50.603 ms  50.899 ms  51.189 ms
 4  193.95.19.78 (193.95.19.78)  61.192 ms  61.509 ms  61.790 ms
 5  193.95.19.73 (193.95.19.73)  62.185 ms  62.497 ms  62.774 ms
 6  193.95.96.145 (193.95.96.145)  64.303 ms  20.855 ms  62.130 ms
 7  193.95.1.98 (193.95.1.98)  61.470 ms  61.781 ms  62.396 ms
 8  72.14.196.233 (72.14.196.233)  62.782 ms  78.939 ms  79.237 ms
 9  216.239.43.156 (216.239.43.156)  63.334 ms  63.702 ms  65.367 ms
10  209.85.252.36 (209.85.252.36)  66.986 ms 209.85.252.194 (209.85.252.194)  77.316 ms 209.85.252.36 (209.85.252.36)  78.599 ms
11  209.85.253.10 (209.85.253.10)  91.684 ms 209.85.253.8 (209.85.253.8)  83.290 ms 209.85.253.10 (209.85.253.10)  92.005 ms
12  72.14.232.78 (72.14.232.78)  84.728 ms  84.020 ms 72.14.232.76 (72.14.232.76)  51.883 ms
13  209.85.254.114 (209.85.254.114)  50.939 ms  52.096 ms 209.85.254.112 (209.85.254.112)  53.610 ms
14  * * *
15  google-public-dns-a.google.com (8.8.8.8)  56.399 ms  58.658 ms  59.578 ms

Do not forget to check you network configuration concerning the DNS part. Run in your terminal the following:

root@sigmoun-redhat ~] dig forbidden-access.org
; &lt;&lt;&gt;&gt; DiG 9.8.1-P1 &lt;&lt;&gt;&gt; forbidden-access.org
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;

That’s it ! At this point you should have successfully done your network configuration.
What you need to remember when doing network configuration in a Red Hat system based, is this directory: /etc/sysconfig/network-script/ which contain all the interface file for network configuration.

Don't be shellfish...twitter Network Configuration and troubleshooting [Red Hat]google Network Configuration and troubleshooting [Red Hat]linkedin Network Configuration and troubleshooting [Red Hat]stumbleupon Network Configuration and troubleshooting [Red Hat]email Network Configuration and troubleshooting [Red Hat]facebook Network Configuration and troubleshooting [Red Hat]

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *