Linux networking cheatsheet

Linux networking: Interfaces and routes

8 common Linux networking tasks.

Show IP addresses

List interfaces and their IP addresses. Add -br for a compact view.

ip -br addr

Show interface state

List interfaces and whether they are up.

ip link show

Show the routing table

List routes, including the default gateway.

ip route

Find which route a destination uses

Show the interface and gateway used to reach an address.

ip route get 8.8.8.8

Find your public IP address

Ask an external service for your public address.

curl -s https://ifconfig.me

Show the ARP table

List devices your machine has talked to on the local network.

ip neigh

Add an IP address temporarily

Assign an extra address to an interface. It is lost on reboot.

sudo ip addr add 192.168.1.50/24 dev eth0

Bring an interface up or down

Enable or disable an interface.

sudo ip link set eth0 up

Caution: Taking down the interface you are connected through will cut off an SSH session.

Was this page helpful?