Linux Networking

Linux Networking basic commands

Most networking is configured by editing two files:

  • /etc/network/interfaces (Ethernet,TCP/IP, bridging)
  • /etc/resolv.con (DNS)

Other networking files

  • /etc/hosts
  • /etc/dhcp3/dhcp.conf
Check networks:
cat /etc/network/interfaces

Typycal default contents
Directive Purpose
auto Indicates the device that should be set up at boot time.
lo Loopback interface.
iface interface
inet Indicates network adaptor has an IPv4 address space
dhcp Network adaptor gets its configuraton from a DHCP server.


cat etc/fstab


Directive Purpose
static Indicates if the adaptor uses fixed IP configuration
address The IP address of the host
netmask Network subnet mask
gateway Gateway address
network The network portion of the IP address
nameserver The IP of a DNS



This is the file to resolve hosts names before containing a DNS, to configure hosts names or internal network hosts

cat /etc/hosts

Network useful commands

Command Description
ping Test that an Internet host is reachable
ifconfig Administer a TCP/IP network interface
sudo /etc/init.d/networking
start restart
Controls network status
route Examine and configure the host's routing table