Friday 11 January 2013

Network Configuration & Troubleshooting



Network Configuration


Linux can support multiple network devices. The device names are numbered and begin at zero and count upwards. For example, a computer running two ethernet cards will have two devices labeled /dev/eth0 and /dev/eth1. Linux network configuration, management, monitoring and system tools are covered in this tutorial. Note, this only cover the basics. I have touched a bit on the difference in Redhat and Debian based systems. There is a ton that could be added to this, but they will come at subsequent postings.

/etc/hosts

It can also be used to resolve hostnames on small networks with no DNS server. For more information, refer to the hosts man page.
127.0.0.1 your-node-name.your-domain.com localhost.localdomain localhost
XXX.XXX.XXX.XXX node-name

Note when adding hosts to this file, place the fully qualified name first. (It helps sendmail identify your server correctly) like this:
XXX.XXX.XXX.XXX superserver.yolinux.com superserver

This informs Linux of local systems on the network which are not handled by the DNS server. (or for all systems in your LAN if you are not using DNS or NIS)

/etc/resolv.conf

This file specifies the IP addresses of DNS servers and the search domain. This configures Linux so that it knows which DNS server will be resolving domain names into IP addresses. If using DHCP client, this will automatically be sent to you by the ISP and loaded into this file as part of the DHCP protocol. If using a static IP address, ask the ISP or check another machine on your network.
Red Hat/Fedora GUI: /usr/sbin/system-config-network (select tab “DNS”).
search name-of-domain.com – Name of your domain or ISP’s domain if using their name server
nameserver XXX.XXX.XXX.XXX – IP address of primary name server
nameserver XXX.XXX.XXX.XXX – IP address of secondary name server

/etc/sysconfig/network

This file specifies routing and host information for all network interfaces.

/etc/nsswitch.conf - System Databases and Name Service Switch configuration file
hosts: files dns nisplus nis

This example tells Linux to first resolve a host name by looking at the local hosts file(/etc/hosts), then if the name is not found look to your DNS server as defined by /etc/resolv.conf and if not found there look to your NIS server.

In the past this file has had the following names: /etc/nsswitch.conf, /etc/svc.conf, /etc/netsvc.conf, … depending on the distribution.

Fedora / Red Hat Network Configuration Files:

/etc/sysconfig/network

Red Hat network configuration file used by the system during the boot process.

/etc/sysconfig/network-scripts/ifcfg-eth0

Configuration settings for your first ethernet port (0). Your second port is eth1.

This file is different depending on the age of the Redhad based system.
/etc/modprobe.conf (kernel 2.6)
/etc/modules.conf (kernel 2.4)
(or for older systems: /etc/conf.modules)

Example statement for Intel ethernet card:
alias eth0 eepro100

Modules for other devices on the system will also be listed. This tells the kernel which device driver to use if configured as a loadable module. (default for Red Hat)

Ubuntu / Debian IP Configuration Files

/etc/network/interfaces

Static IP example:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 208.88.34.106
netmask 255.255.255.248
broadcast 208.88.34.111
network 208.88.34.104
gateway 208.88.34.110

Dynamic IP (DHCP) example:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto ath0
iface ath0 inet dhcp
auto wlan0
iface wlan0 inet dhcp

Interfaces:


lo: Loopback interface (network within your system without slowing down for the real ethernet based network)



eth0: First ethernet interface card



wlan0: First wireless network interface

Also see “man interfaces

Network Troubleshooting


1- First check that your interface (Network adapter ) is enabled or not using: ifconfig

2- To make sure there is no internal problem.

ping to the loop back address ping 127.0.0.1


if there is no response service network restart if same repeats check network settings again.


3- check cable problem from ethtool eth0


if everything is fine then last line will show Link detected: yes

if link is not detected plug it or change the cable according to need and problem


4-check the gateway settings in

/etc/network and

/etc/sysconfig/network-scripts/ifcfg-eth0

And check DNS settings in

/etc/resolv.conf

system-config-network

netstat

route

service iptables stop

( only disable the firewall for testing and dont forget to turn it on)

check boot messages if eth card is detected at boot time or not

cat /var/log/dmesg | grep -i eth0



or

dmesg | grep -i eth0

to check table of network interfaces

netstat -i

for more advanced troubleshooting

lspci | less

or

lspci | grep ethernet

to check all PCI buses and devices connected to them

These are enough to troubleshoot if still problem persist try installing drivers , check kernel related problems , check is there any need to recompile the kernel etc

No comments:

Post a Comment