ViewAnd configure the route list. For example, the query command is:
# Netstat-Rn
Routing tables
Destination Gateway Flags Refs Use If PMTU Exp Groups
Route Tree for Protocol Family 2 (Internet):
default 10.0.100.250 UGc 0 0 en0 - - -
10.0.100.0 10.0.100.150 UHSb 0 0 en0 - - - =>
10.0.100/24 10.0.100.150 U 2 2 en0 - - -
10.0.100.255 10.0.100.150 UHSb 0 3 en0 - - -
127/8 127.0.0.1 U 0 353 lo0 - - -
Route Tree for Protocol Family 24 (Internet v6):
::1 ::1 UH 0 0 lo0 16896 - -
The red part indicates the default route, that is, the gateway address. You can use the following command to add a default route:
# Route add default 10.0.100.250 or
# Route add 0 10.0.100.250
It indicates that the IP address is not specified, or the target path is 0, that is, all addresses, using the route 10.0.100.250. In fact, this IP address is the gateway. However, the added route is only added inRoute table(Dynamic Routing), instead of writing it in the ODM database. If you want to write it in the ODM database, you can simply
# Smit route, or similar commands
# Chdev-l inet0-a route = "net,-route count, 0, 0, 10.0.100.250 ″
As shown in the preceding figure, the route 10.0.100.250 will be used for the target address 0, which is actually the default route. In this way, the added route is a static route.
The following is an example of adding a dynamic route and deleting a dynamic route. The following shows that route 10.0.100.htm is used for the target subnet 10. 10. *. */24, where/24 indicates the subnet mask.
# Route add-net 10.10.0.0-netmask 255.255.255.0 10.0.100.htm
You can see the following information from netstat-RN.
10.10/24 10.0.100.251 UG 0 0 en4 - -
To delete this dynamic route, run the following command:
# Route Delete 10.10.0.0 10.0.100.htm
The following is an example of adding a static route and deleting a static route. This time, we only use the route 10.0.100.htm for the host 10.10.10.100 instead of for the network segment.
# Chdev-l inet0-a route = "host,-route count, 0, 10.10.10.100, 10.0.100.20 ″
The following information is displayed in netstat-Rn:
10.10.10.100 10.0.100.251 UGH 0 0 en4 - -
You can also use the following command to delete the static route
# Chdev-l inet0-A delroute = "host, 10.10.10.100, 10.0.100.20 ″
If you want to clear allRoute tableOr refreshRoute table, You can use the following command. Note: This command only refreshes (actually clears) the currentRoute tableThe static routes in the ODM database are not cleared. Therefore, the static routes written in the ODM database will continue to take effect after being restarted.
In addition, do not execute this command easily, because if you connect to the machine using different network segments, clearRoute tableYou can immediately disconnect your network.
# Route-F
default 10.0.100.250 done
dbtest loopback done
# Netstat-Rn
Routing tables
Destination Gateway Flags Refs Use If Exp Groups
Route Tree for Protocol Family 2 (Internet):
10.0.100.0 10.0.100.150 UHSb 0 0 en0 - - - =>
10.0.100/24 10.0.100.150 U 2 2 en0 - - -
10.0.100.255 10.0.100.150 UHSb 0 3 en0 - - -
127/8 127.0.0.1 U 0 353 lo0 - - -
Route Tree for Protocol Family 24 (Internet v6):
::1 ::1 UH 0 0 lo0 - -
Correct use of routes can reduce network jumps and even greatly increase network access speeds.