linux beginner
Now Reading
Route Command in linux with examples
0

Route Command in linux with examples

Route Add Command in Linux with examples

Routing is the basic design for internet protocol. This protocol helps in transferring packet to the right machines. A router controls the traffic and sends packet to the destination network. Route add command in Linux is explained in this article with an example.

Options
-A is used to specify the specific address family.
-F option is used for the kernel’s FIB  routing table.
-C option is used to operate the kernel’s routing cache.

-v option is used for verbose operation.
-n  displays the numerical addresses.
-e option is used to display the routing table in netstat-format.
-arp Manipulate the system ARP cache.
ifconfig— View or modify the configuration of network interfaces.
ip— Display and manipulate information about routing, devices, policy routing and tunnels. netstat— Print information about network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
-ee  option will generate a very long line from the routing table with all parameters.
-del Delete a route.
-add add a new route.
-net the target is a network.
-host the target is a host.
netmask NM to add a network route, the netmask is to be used.
gw GW route packets via a gateway.
NOTE:   Set up a static route to the gateway to make sure that the specified gateway should be available.

Examples of Route add command

To fetch the information about the routing table

[root@linuxhelp ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.5.1     0.0.0.0         UG    1024   0        0 eno16777736
192.168.5.0     0.0.0.0         255.255.255.0   U     0      0        0 eno16777736

To add network 

Use route command along with the net switch, the subnet mask and gateway values to add a network.

[root@linuxhelp ~]# route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.5.1 eno16777736
[root@linuxhelp ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.5.1     0.0.0.0         UG    1024   0        0 eno16777736
192.168.5.0     192.168.5.1     255.255.255.0   UG    0      0        0 eno16777736
192.168.5.0     0.0.0.0         255.255.255.0   U     0      0        0 eno16777736

To add particular ip address

By using –host along with the router command to add a particular IP address.

[root@linuxhelp ~]# route add -host 192.168.5.191 gw 192.168.5.1 eno16777736
[root@linuxhelp ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.5.1     0.0.0.0         UG    1024   0        0 eno16777736
192.168.5.0     192.168.5.1     255.255.255.0   UG    0      0        0 eno16777736
192.168.5.0     0.0.0.0         255.255.255.0   U     0      0        0 eno16777736
192.168.5.191   192.168.5.1     255.255.255.255 UGH   0      0        0 eno16777736



Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.

For more help topics browse our website www.linuxhelp.com

Be the first to comment, we value your suggestions. For further queries please comment below.

Leave a Response