Linux Networking


Linux Networking Commands

Common commands:

ip Command to show and manipulate network devices and routing
ifconfig Deprecated command for configuring network devices
route Deprecated command for managing network routes
ifup/down Bring a network interface up or down
ss Show socket connections
netstat Deprecated command for showing network connection
arp Deprecated command for showing ARP information


Configuring an IP address

# Assign an IP address to a specific interface
ip addr add dev eth1

# Set an IP with a specific netmask
ip addr add dev eth1

# Remove an IP address (best to use full CIDR)
ip addr del dev eth1

# Show all interfaces
ip addr show

# Show a specific interface
ip addr show dev eth1

This replaces ifconfig.

Configuring network interfaces

# Bring an interface up
ip link set eth1 up

# Bring an interface down
ip link set eth1 down

# Set the MTU
ip link set eth1 mtu 9000

This replaces ifconfig.

Configuring the routing information

# Adding the default gateway
ip route add default via

# Add a static route
ip route add via

# Remove a static route
ip route del

# Show route table
ip route show

This replaces route.

ARP table management

# Show ARP table
ip neigh

# Show verbose ARP table
ip -s neigh

# Add new ARP table entry
ip neigh add lladdr 1:2:3:4:5:6 dev eth1

# Remove ARP table entry
ip neigh del dev eth1

This replaces arp.

Showing network socket information

# Show all network stats

# Show all TCP network stats without DNS lookups
ss -nt

# Show multicast addresses
ip maddr

This replaces netstat.

Networking on Red Hat

The default networking daemon on CentOS 7
A simple curses-based text user interface (TUI) for NetworkManager
A command-line tool provided to allow users and scripts to interact with NetworkManager

Configuring networking in Red Hat

Interface specific information is stored in ifcfg files in this directory
A file that contains global network settings (i.e. VPNs, etc).


# Static


Notifying NetworkManager of changes

NetworkManager needs to be made aware of the change by running:

nmcli connection reload

Or if you only want it to change the file you changed:

nmcli con load /etc/sysconfig/network-scripts/ifcfg-eth0

Bringing the interface up:

ifup eth0

# OR

nmcli con up eth0

Consistent Network Device Naming

Device Naming Hierarchy

By default, systemd uses the following policies for naming:

  1. Using Firmware or BIOS index numbers for on-board devices (i.e. eno1)
  2. Using Firmware or BIOS provided PCI Express hotplug slot index numbers (i.e. ens1)
  3. Using physical location of the connector of the hardware (i.e. enp2s0)
  4. Using interfaces MAC address (i.e. enx78e7d1ea46da)
  5. Fallback to unpredictable kernel naming scheme (i.e. eth0)

Can be disabled with net.ifnames=0 biosdevname=0 set at boot

Predictable naming formats

Two character prefixes:

en Ethernet
wl Wireless (WLAN)
ww Wireless wide network (WWAN)

Predictable naming formats

Device Name Types:

on-board device index number
hotplug slot index number
MAC address
PCI geographical location

Example:: enP2p1s0f4

Advanced Networking

Ethernet Bonding
Bind multiple interfaces into a single bonded, channel. Channel bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy.
Networking Teaming
Newer implementation of ethernet bonding. Provides an API interface which user-space applications can use.

Advanced Networking

Network Bridges
Link-layer device which forwards traffic between networks based on MAC addresses. A software bridge can be used within a Linux host in order to emulate a hardware bridge, for example in virtualization applications for sharing a NIC with one or more virtual NICs.
VLAN tagging
Using tagged VLANs on interfaces.


Class Announcements