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&mdash 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.
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 &ndash 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

FAQ
Q
How to delete a route?
A
Use "-del" to delete the route.
Q
What is the command to view the verbose using route commands?
A
By using this command you can view the verbose
Syntax: " route -v"
Q
How to display the numerical address using Route command?
A
To display the numerical address use this commands
Syntax: "route -n"
-n displays the numerical addresses.
Q
How to navigate to man page for the route?
A
You can navigate by entering "man router" command from command line.
Q
It is possible to track Wifi?
A
No. you can route only wired Networks