Linux network troubleshooting If your network connection is not working..
Quick troubleshoot Check that network cable is connected and one of NIC’s leds is lit. Also check that computer is powered on! If possible go to switch/hub where your machine is connected and check that connection led is lit. Is network leds seem to be ok, restart network with following command: service network restart (works with CentOS, fedora core and redhat) /etc/init.d/network restart (should work with other distributions also) Check what ifconfig tells you. If you’re not root user, you can check ifconfig with following command: /sbin/ifconfig
Connection and ip-address seems to be ok. Interface has received and sent some packages. ~]# /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 00:10:5A:39:AC:1D inet addr: Bcast: Mask: UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets: errors:7 dropped:0 overruns:0 frame:7 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes: (50.0 MiB) TX bytes: (223.1 MiB) Interrupt:11 Base address:0xd000
If your ip-address isn’t shown, you most probably have DHCP enabled and DHCP-server is not giving you any address. If you don’t get ip-address Linux might interface disabled. You can use dhclient command manually to restart dhcp search. ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:10:5A:39:AC:1D UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:14 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 MiB) TX bytes:0 (0.1 MiB) Interrupt:11 Base address:0xd000
~]# /sbin/route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface U eth U eth U eth UG eth0 Check that default GW exists! If you have two network adapters check that there’s only one default GATEWAY!
CentOS network configuration files Are located in /etc/sysconfig –folder ~]# more /etc/sysconfig/network NETWORKING=yes HOSTNAME=firewall.datacom.intra.fi GATEWAY= The default GATEWAY can be set in network file or ifcfg-ethX file. It’s easier to troubleshoot if you have gateway set in one file only. If you have two network adapters check that there’s only one default GATEWAY!
CentOS Interface configuration file (static) ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static ONBOOT=yes TYPE=Ethernet HWADDR=00:50:8B:5D:EE:1A IPADDR= NETMASK= NETWORK= BROADCAST= Static configuration for interface eth0. You must define at least IPADDR and NETMASK. If you have other than basic class C network specify also BROADCAST and NETWORK addresses. Remember to change BOOTPROTO to static if you’re setting static address manually!
CentOS Interface configuration file (dynamic) ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:50:8B:5D:EE:1A ONBOOT=yes TYPE=Ethernet Dhcp gets all addresses automatically, only thing you need to set is BOOTPROTO. If your network still doesn’t work, you can add network configuration manually with following commands: ifconfig eth netmask broadcast route add default gw
Ubuntu & Debian Interface configuration file (static) Are located in /etc/network –folder. Most of the sites in internet are missing line auto eth0, which makes your system not to refetch interface addresses from the file. more /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 primary network interface auto eth0 iface eth0 inet static address netmask gateway
Ubuntu & Debian Interface configuration file (dynamic) Are located in /etc/network –folder more /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 primary network interface auto eth0 iface eth0 inet dhcp
Quick DNS checkup Name servers for machine are defined in /etc/resolv.conf –file. coursefiles]# more /etc/resolv.conf search dc.turkuamk.fi nameserver nameserver Easy way to check that name servers work: 1) ping 2) ping If both pings works, then name servers are working If only the last ping works, then you have some problems with your name server configuration If both pings fail, check ifconfig and default route