Linux Networking: Routing, VLANs, Bridges, and Tunnels

Linux routing tables, policy routing, bridges, VLANs, bonds, and tunnel configuration commands.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Routes and Gateways

Inspect and manipulate routing tables and policy routes.

Show routes

Display the main routing table.

bashLINUXiprouterouting
bash
ip route show

Display the main routing table.

Resolve route for destination

Show which route and source address will be used.

bashLINUXiproutediagnostics
bash
ip route get 8.8.8.8

Show which route and source address will be used.

Add default route

Set a default gateway.

bashLINUXiproutegateway
bash
sudo ip route add default via 192.168.1.1 dev eth0

Set a default gateway.

Delete default route

Remove the default gateway.

bashLINUXiproutegateway
bash
sudo ip route del default

Remove the default gateway.

Add static route

Add a route for a remote network.

bashLINUXiproutestatic
bash
sudo ip route add 10.20.0.0/16 via 192.168.1.254 dev eth0

Add a route for a remote network.

Delete static route

Remove a static route.

bashLINUXiproutestatic
bash
sudo ip route del 10.20.0.0/16

Remove a static route.

Show policy routing rules

Display source-based and policy routing rules.

bashLINUXippolicy-routingrules
bash
ip rule show

Display source-based and policy routing rules.

Add source routing rule

Route traffic from a source CIDR using a specific table.

bashLINUXippolicy-routingsource
bash
sudo ip rule add from 10.10.0.0/24 table 100

Route traffic from a source CIDR using a specific table.

Add route to custom table

Insert a route into an alternate routing table.

bashLINUXiproutetable
bash
sudo ip route add default via 10.10.0.1 dev eth1 table 100

Insert a route into an alternate routing table.

Run tracepath

Trace MTU and path to a host.

bashLINUXtracepathpathmtu
bash
tracepath example.com

Trace MTU and path to a host.

Run traceroute

Trace path hops to a host.

bashLINUXtraceroutepathhops
bash
traceroute example.com

Trace path hops to a host.

Bridges, VLANs, and Tunnels

Work with bridges, VLAN subinterfaces, bonds, and tunnels.

Show bridge forwarding database

Inspect learned MAC addresses on bridges.

bashLINUXbridgefdbmac
bash
bridge fdb show

Inspect learned MAC addresses on bridges.

Create GRE tunnel

Create a GRE tunnel interface.

bashLINUXgretunnelip
bash
sudo ip tunnel add gre1 mode gre local 10.0.0.1 remote 10.0.0.2 ttl 255

Create a GRE tunnel interface.

Show ARP/neighbor cache

Display IPv4 ARP and IPv6 neighbor entries.

bashLINUXarpneighborip
bash
ip neigh show

Display IPv4 ARP and IPv6 neighbor entries.

ARP ping a host

Probe L2 reachability on the local subnet.

bashLINUXarpingl2reachability
bash
sudo arping -I eth0 192.168.1.1

Probe L2 reachability on the local subnet.

Recommended next

No recommendations yet.