Recent Posts
- jQuery attrAugust 12, 2021
- jQuery mouseenterAugust 9, 2021
- jQuery ToggleclassAugust 6, 2021
- jQuery attr
Introduction to Linux Route Command
Routing is the process of sending IP packets from one source to the destination. For example whenever we send an electronic mail to your relatives residing in another country or even across the same country/street then actually we are sending a series of IP packets/datagrams from our computer to relatives computer.
How Does it Work?
Considering the above example, when our computer sends the IP packets that contain information of mail to a gateway, then the gateway forwards this packet to other gateways/router. This process will happen until it arrives at the relative’s computer and after that, she/he reads the message. All the processes involved in the above use different types of protocols like FTP, IRC, HTTP and many more.
On Linux & UNIX, IP packets that contain information is stored in a type of kernel structure which is termed as a routing table. We can change this table while configuring our computer to communicate with another computer across a network.** Routing is done by the gateways or in common terms routers.
What is Routers?
It is a device that forwards the IP packets between two computers using different protocols. The router maintains a routing table.
Types of Routing
Types of routing are given below:
Different Commands of Linux Route
Below are the Linux route commands:
Command:
route Options
It is command utility to view and manipulate IP routing tables i.e. linking between source and destinations. This command will work both in windows and Unix os.
Options:
Now let us understand all the route command through an example:
We can get the information from netstat program:
Command:
netstat -r
It gives lists if the network connection is it Transmission Control Protocol, Printers, LAN, Routing tables, interfaces multicasts, etc.
Command:
route
The route is given below:
Command:
ip route show or ip route list
This will show the IP routing and lists. This will give the same result:
Command:
route add default gw 192.167.1.254 eth1
It will route all the traffic via 192.168.1.254 gateway connected through eth1 network interface.
Command:
ip route add 192.167.1.0/25 dev eth1
It will route all the traffic through 192.167.1.254 gateway connected through the eth1 network interface.
Command:
route -Cn
As we know kernel is maintaining route cache information to route the packet speedily by using the -C option.
Command:
route add -host 192.167.2.52 reject
In case we want to reject a particular host or network to receive packets then we use to reject the command. After that we need to check whether that host/network is reachable or not :
Command:
ping 192.168.1.51
Output: Network is unreachable
Command:
Make 192.167.3.* Accessible from 192.167.1.*
Here we have to add routing information so that we are fully able to reach 192.168.3. series IP address from 192.167.1. series. The basic understanding is that we have a GATEWAY machine. So on every machine in 192.168.1.* network a default gateway will be added as mentioned below.
Command:
route add default gw 192.167.1.10
Now, when 192.167.1.1 ping 192.167.3.1 it will redirect to GATEWAY through 192.168.1.10. In the GATEWAY we need to add the below-mentioned routing entry.
Command:
route add -net 192.167.3.0 netmask 255.255.254.0 gw 192.167.3.10
All the packet was addressed to 192.167.3.* network will be directed through the 192.167.3.10 gateway interface which will then deliver the packets to the destination machine.
Merits
Demerits
MCP is the right place for best computer Courses institute and advance Courses in Mohali and Chandigarh.The Complete Programming Academy can change your life – providing you with the knowledge, skills, and performance in a second language which helps you to excel in your job.You can also Contact us for 6 month industrial training institute in Mohali.