General Usage of Linux Route
Route ConfigurationRoute
Route: displays or configures local route information.
The main configuration information of a route table configuration is:
Configuration item |
Meaning |
Target |
Destination Ip host address or Ip address |
Gw |
Next Hop address |
Dev |
Next Hop Network Interface |
If an ip report needs to be sent from the local machine or an ip datagram is forwarded, Linux will first find out whether the Target ip address matches the Target configuration in the route information table maintained by the system, if yes, the ip address is sent to the address specified by Gw in the configuration. if no route configuration is found, the datagram is sent to the defaultThe gateway address.
Usage:
Route [options]
Instance used:
A) display route informationRoute-n
B) set the default value.Gateway Configuration
Route add default gw 192.168.9.1 dev eth1
C) delete the default value.Gateway Configuration
Route del default gw 192.168.9.1 dev eth1
D)Route entry added to the target host:
Route add-host 192.168.9.8 gw 192.168.9.1 dev eth1
E)Route entry added to the target network:
Route add-host 192.168.9.8 netmask 255.255.255.0 gw 192.168.9.1 dev eth1
F) Route entries to the target host:
Route del-host 192.168.9.8 gw 192.168.9.1 dev eth1
G) Route entries to the target network:
Route del-host 192.168.9.8 netmask 255.255.255.0 gw 192.168.9.1 dev eth1