Skip to main content

Linux Networking

Routing

View routes

ip route

ip route

Adding a route

ip addr add 192.168.1.100/24 dev eth0

Add a gateway

ip route add default via 192.168.1.1 dev eth0

Add a route of a subnet to a gateway

ip route add 10.1.2.0/24 via 10.1.2.1 dev eth0

null route (blackhole)

ip route add blackhole 10.1.2.130 # For an IP
ip route add blackhole 10.1.2.10/24 # For a subnet
ip route del blackhole 10.1.2.130 # Remove from blackhole

null route an ip list

for string in $(cat ips.txt); do ip route add blackhole $string; done