Linux Network Config

Ethernet

In Linux, ethernet interfaces are labelled as eth0, eth1, …

Display Hardware Information

lspci

pci network cards

lsusb

usb network cards

Display Interface Information

ip addr
ip link
ip -s link

#ifconfig # obsolete

Interface Terms

eth0

ethernet interface

lo

loopback interface (127.0.0.1)

rx

receive

tx

transmit

Enable/Disable Interfaces

ifup eth0
ifdown eth0

Network Config Files

This changes for different distributions.

Read the document for your linux distribution to understand how to config those.

Debian Interface Config

man interfaces
sudo vim /etc/network/interfaces

DNS Config

/etc/resolv.config

Hostname Config

hostname
hostname <some-name>
sudo vim /etc/hostname

Hosts

Static table lookup for hostnames.

/etc/hosts

Network Testing Commands

Test connection

ping IP
ping URL

DNS

host URL
dig URL

Display routing table

ip route

Trace route (traces the routing devices)

traceroute URL/IP
# there might be some restrictions for output

Both traceroute and ping

  • Updates dynamically
  • Continuously send packets to calculate the loss rate
  • Contact the network provider of the ones with high loss rate
mtr URL

Network Troubleshoot

From lower to higher, from inner to outer.

  1. Check config files
    • ip
    • subnet mask
    • gateway
    • DNS
  2. ping gateway
  3. DNS
    • host