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

  • -n

    Shows numeric addresses, without resolving names.

  • add

    Adds a route.

  • del

    Removes a route.

  • default gw puerta

    Sets the default gateway.

  • -net red netmask máscara

    Specifies a destination network and its mask.

  • dev interfaz

    Forces the route to use that interface.

Usage examples

  • route -n

    Shows the routing table with numbers.

  • sudo route add default gw 192.168.1.1

    Sets 192.168.1.1 as the gateway.

  • sudo route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.254

    Sends traffic for the 10.0.0.0/24 network through another router.

  • sudo route del default

    Removes 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.

Related commands