Custom Search

Ubuntu route add command guide

Ubuntu route add command guide for a new user. The route add command actually is one of route command options used to modify a routing table. The route add option can create a new route, add new network, modify current routing table, and add new gateway.


This is the online help available with route command. You can view this help with route --help command.


Usage: 
route [-nNvee] [-FC] []   List kernel routing tables
route [-v] [-FC] {add|del|flush}... Modify routing table for AF.
route {-h|--help} []   Detailed usage syntax for specified AF.
route {-V|--version}   Display version/author and exit.
-v, --verbose          be verbose
-n, --numeric          don't resolve names
-e, --extend           display other/more information
-F, --fib              display Forwarding Information Base (default)
-C, --cache            display routing cache instead of FIB=Use '
-A ' or '--'; 
default: inet
List of possible address families (which support routing):
inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)netrom (AMPR NET/ROM) 
ipx (Novell IPX) ddp (Appletalk DDP)x25 (CCITT X.25)

This is the description:


DESCRIPTION
Route manipulates the kernel's IP routing tables.  Its primary  use  is
to  set up static routes to specific hosts or networks via an interface
after it has been configured with the ifconfig(8) program.
When the add or del  options  are  used,  route  modifies  the  routing
tables. Without these options, route displays the current contents of
the routing tables.

The route command with no option will print the routing table. See an example below:


luzar@ubuntu:~$ route
Kernel IP routing table
Destination  Gateway         Genmask        Flags Metric Ref  Use Iface
localnet     *               255.255.255.0  U     0      0     0  eth0
default      mygateway1.ar7  0.0.0.0        UG    100    0     0  eth0
luzar@ubuntu:~$

Here is an example of Ubuntu route add command to create a new network route:


luzar@ubuntu:~$ sudo route add -net 10.21.35.0 netmask 255.255.255.0 dev eth0 
[sudo] password for luzar:
luzar@ubuntu:~$ route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref  Use Iface
localnet        *               255.255.255.0   U     0      0     0  eth0
10.21.35.0      *               255.255.255.0   U     0      0     0  eth0 
default         mygateway1.ar7  0.0.0.0         UG    100    0     0  eth0
luzar@ubuntu:~$

You can see the new route is added in the routing table above.

No comments:

Post a Comment

Please keep comment relevant and strictly no spam will be tolerated. Thank you.