route
Linux · Network · reference only
What it does
Shows and modifies the system routing table with the classic syntax. Its modern replacement is ip route.
Syntax
route [opciones] route add|del [opciones] destino
Options and parameters
-nShows numeric addresses, without resolving names.
addAdds a route.
delRemoves a route.
default gw puertaSets the default gateway.
-net red netmask máscaraSpecifies a destination network and its mask.
dev interfazForces the route to use that interface.
Usage examples
route -nShows the routing table with numbers.
sudo route add default gw 192.168.1.1Sets 192.168.1.1 as the gateway.
sudo route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.254Sends traffic for the 10.0.0.0/24 network through another router.
sudo route del defaultRemoves the default route.
Notes and common mistakes
- It belongs to the net-tools package, which is not installed on Debian 12.
- Routes added this way are not permanent.