route Command: Tutorial & Examples
Modify the IP routing table
The route
command is used to manipulate the IP routing table. It can be used to display the current routing table, add new routes, or delete existing ones.
To display the current routing table, use the command route -n
.
To add a new route to the routing table, use the command route add -net [destination_network] netmask [subnet_mask] gw [gateway_IP]
.
For example, to add a route to the network 10.0.0.0
with a subnet mask of 255.255.255.0
and a gateway of 192.168.1.1
, the command would
be route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.1
.
To delete a route from the routing table, use the command route del -net [destination_network] netmask [subnet_mask] gw [gateway_IP]
.
It's worth noting that the routing table can also be manipulated using the ip
command, which is considered more powerful and flexible than the route
command.