When you need to display the routing table in the Linux system operation, you will be exposed to the route command, then what is the usage of the route command? The following system home Xiaobian will give you an example of how to use the route command in Linux. Interested friends may wish to understand it.
In the Linux system, set the route usually to address the following issues: the Linux system in a local area network, local area network has a gateway that allows the machine to access Internet, you will need these machines The IP address is set to the default route of the Linux machine. It should be noted that the route is directly executed on the command line to add a route, which will not be saved permanently. When the network card is restarted or the machine is restarted, the route is invalid; you can add the route command in /etc/rc.local to ensure that the route is guaranteed. This route setting is permanently valid.
1. Command Format:
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]
2. Command Function:
The Route command is used to operate the kernel-based ip routing table. Its main function is to create a static route to specify a host or a network through a network interface, such as eth0. When the “add” or “del” parameter is used, the routing table is modified. If there is no parameter, the current content of the routing table is displayed.
3. Command parameters:
-c Show more information
-n Do not resolve names
-v Display detailed processing information
-F Display sending information
-C Display Route Cache
-f Clears the routing table for all gateway entries.
-p Makes the route permanent when used with the add command.
add: Add a new route.
del: Delete a route.
-net: The destination address is a network.
-host: The destination address is a host.
netmask: When adding a network route, you need to use a network mask.
gw: Routing packets through the gateway. Note that the gateway you specify must be reachable.
metric: Set the number of route hops.
Command Specify the command you want to run (Add/Change/Delete/Print).
Destination Specifies the network destination for this route.
mask Netmask Specifies the network mask (also known as the subnet mask) associated with the network target.
Gateway Specifies the forward or next hop IP address that the address set and subnet mask defined by the network target can reach.
metric Metric Specifies an integer cost value for the route (from 1 to 9999) that can be used when selecting among multiple routes in the routing table that best matches the forwarded packet destination address.
If Interface specifies an interface index for an interface that can access the target. To get a list of interfaces and their corresponding interface indexes, use the display function of the route print command. Interface indexing can be done using decimal or hexadecimal values.
4. Example:
Instance 1: Display Current Route
Command:
The code is as follows:
route
route -n
Output:
The code is as follows:
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.120.0 * 255.255.255.0 U 0 0 0 eth0
e192.168.0.0 192.168.120.1 255.255.0.0 UG 0 0 0 eth0
10.0 .0.0 192.168.120.1 255.0.0.0 UG 0 0 0 eth0
default 192.168.120.240 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.120.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.0.0 192.168.120.1 255.255.0.0 UG 0 0 0 eth0
10.0.0.0 192.168.120.1 255.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.120.240 0.0.0.0 UG 0 0 0 Eth0
Previous123Next page Total 3 pages
We all know that Linux system startup is very fast, so what content does the Linux
Linux many operations, lftp can be used for ftp file download and upload, login ftp
The PostgreSQL database is installed in Linux Hill, but it can only be accessed loc
Linux users generally use the active mode when using the vsftpd server, but the vsf
Linux installation using the monitoring software Collectl method
RHEL 6.0 system sudo switch user is too slow how to do?
Ubuntu method to install JDK environment variables Ubuntu configuration JDK steps
Linux scp command usage example summary
How to delete git branches in batches in Linux system
Linux system prompts can not get the lock /var/lib/dpkg/lock how to do?
CentOS 6.2 upgrade yum prompt libotf.so.0 error how to do?
How to restart Tomcat regularly on Linux system
How to modify the file time of the Linux system
Linux installation using fail2ban method
Prerequisite knowledge before using MyEclipse
Teach you to quickly insert a capture screen in Word
Linux background running and closing, view background tasks
Win10 manual method of adding wireless network
How does Win10 enter bios? What if Win10 can't enter bios?
How to pronounce the ellipsis, the ellipsis shortcut
How to lock the computer on the Win7 computer
How does Win7 display the file suffix name
Faster than Win7 11 times! Win8 wireless network connection speed is amazing