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
Show routes
ip route show

# Display the main routing table.

Resolve route for destination
ip route get 8.8.8.8

# Show which route and source address will be used.

Add default route
sudo ip route add default via 192.168.1.1 dev eth0

# Set a default gateway.

Delete default route
sudo ip route del default

# Remove the default gateway.

Add static route
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
sudo ip route del 10.20.0.0/16

# Remove a static route.

Show policy routing rules
ip rule show

# Display source-based and policy routing rules.

Add source routing rule
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
sudo ip route add default via 10.10.0.1 dev eth1 table 100

# Insert a route into an alternate routing table.

Run tracepath
tracepath example.com

# Trace MTU and path to a host.

Run traceroute
traceroute example.com

# Trace path hops to a host.

## Bridges, VLANs, and Tunnels
Show bridge forwarding database
bridge fdb show

# Inspect learned MAC addresses on bridges.

Create GRE tunnel
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
ip neigh show

# Display IPv4 ARP and IPv6 neighbor entries.

ARP ping a host
sudo arping -I eth0 192.168.1.1

# Probe L2 reachability on the local subnet.

Recommended next

No recommendations yet.