route Linux Commands

What is Linux route Command?


route COMMAND:

route command displays routing table resides in kernel and also used to modify the routing table.The tables which specifies how packets are routed to a host is called routing table.


route [options]


-n dispalys routing table in numerical[IP Address] format
-e dispalys routing table in Hostname format
add Adds a new route to the routing table
del Deletes a route from the routing table

Options used with add and del :
-net Indicate the target is network
-host Indicate the target is host
gw Specifies the gateway of target host/network
netmask Used to specifiy the subnet-mask of destination network/host
dev Specify the device or interface where the packets will be sent
reject rejects the packets sent to particular route/host


  1. To dispaly the routing table:
    route -n

    The above command will print:

    DestinationGatewayGenmaskFlagsMetricRefUseIface U 000eth0 U 000eth0

    In above table:
    Destination -Indicates the IP address of desination host/network
    Gateway -Indicates gateway from which desination host/network could be reached
    Genmask -Indicates the subnetmask destination
    Flags -Indicates the current status of route
    • U - Route is up
    • H - Target is a host
    • G - Use gateway
    Iface -Indicates the interface
  2. To add static route to a network in the routing table:
    route add -net netmask gw dev eth0

    In above command:
    add -Indicates that the route is added to routing table.
    -net -Indicates that desination is a network. IP address of destination network.
    netmask-Indicates the subnetmask of destination network.
    gw the gateway of destination network.
    dev eth0-Indicates that the packets are routed via the interface eth0.
  3. To delete a route from the routing table:
    route del -net netmask gw dev eth0
    The above command will delete the route to from the routing table.

Ask Questions

Ask Question