One computer has two lines, one Telecom IP address, and one Unicom IP address. when accessing China Telecom, the system automatically follows the China Unicom line. We can use the following command:
We can use route/? In Cmd for all ROUTEDOS commands /? To view his help information.
Let's take a look at his help.
Manipulates network routing tables.
ROUTE [-f] [-p] [command [destination]
[MASK netmask] [gateway] [METRIC metric] [IF interface]
-F Clears the routing tables of all gateway entries. If this is
Used in conjunction with one of the commands, the tables are
Cleared prior to running the command.
-P When used with the ADD command, makes a route persistent guest SS
Boots of the system. By default, routes are not preserved
When the system is restarted. Ignored for all other commands,
Which always affect the appropriate persistent routes. This
Option is not supported in Windows 95.
Command One of these:
PRINT Prints a route
ADD Adds a route
DELETE Deletes a route
CHANGE Modifies an existing route
Destination Specifies the host.
MASK Specifies that the next parameter is the 'netmask' value.
Netmask Specifies a subnet mask value for this route entry.
If not specified, it defaults to limit 255.
Gateway Specifies gateway.
Interface the interface number for the specified route.
METRIC specifies the metric, ie. cost for the destination.
All symbolic names used for destination are looked up in the network database
File NETWORKS. The symbolic names for gateway are looked up in the host name
Database file HOSTS.
If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(Wildcard is specified as a star '*'), or the gateway argument may be omitted.
If Dest contains a * or ?, It is treated as a shell pattern, and only
Matching destination routes are printed. The '*' matches any string,
And '? 'Matches any one char. Examples: 157. *. 1,157. *, 127. *, * 224 *.
Diagnostic Notes:
Invalid MASK generates an error, that is when (DEST & MASK )! = DEST.
Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
The route addition failed: The specified mask parameter is invalid
(Destination & Mask )! = Destination.
Examples:
> Route PRINT
> Route ADD 157.0.0.0 MASK route 0.0.0 157.55.80.1 METRIC 3 IF 2
Destination ^ mask ^ gateway metric ^
Interface ^
If IF is not given, it tries to find the best interface for a given
Gateway.
> Route PRINT
> Route PRINT 157 *... Only prints those matching 157 *
> Route CHANGE 157.0.0.0 MASK route 0.0.0 157.55.80.5 METRIC 2 IF 2
CHANGE is used to modify gateway and/or metric only.
> Route PRINT
> Route DELETE 157.0.0.0
> Route PRINT
Route-display/Operation IP address routing table
Overview SYNOPSIS
Route [-CFvnee]
Route [-v] [-A family] add [-net |-host] target [netmask Nm] [gw Gw] [metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn] [reinstate] [[dev] If]
Route [-v] [-A family] del [-net |-host] target [gw Gw] [netmask Nm] [metric N] [dev] If]
Route [-V] [-- version] [-h] [-- help]
DESCRIPTION
The route program operates on the kernel IP address routing table. It is mainly used to set static routes for the specified host or network through the interface configured by the ifconfig (8) program.
OPTIONS
-V
Select detailed operation mode
-A family
Use the specified address family (such as 'inet' and 'inet6 ').
-N
The address is displayed in the form of a number instead of an interpreted host name. This item is useful for trying to detect the cause of a route failure on the Domain Name Server.
-E
Use the netstat (8) format to display the routing table. -Ee will generate a large amount of information including all the parameters of the selector table.
-Net
The route destination is the network.
-Host
The route destination is the host.
-F
Displays the FIB routing table of the kernel. The format can be changed using the-e and-ee options.
-C
Displays the route cache of the kernel.
Del
Delete a route.
Add
Add a route.
Target
Specify the target network or host. IP addresses or host/network names can be in dotted-decimal format.
Netmask Nm
Specify a network mask for the added route.
Gw Gw
Specify a gateway for any group sent to the target network/host. Note: The specified gateway must be reachable first. That is to say, a static route must be specified in advance for the gateway. If you specify the gateway address for one of the local interfaces, the gateway address is used to determine how the Group on this interface will be routed. This is compatible with the BSD style.
Metric M
Set the routing Value Field in the routing table (used by the routing process) to M.
Mss M
Set the maximum length of TCP packets connected based on this route to M bytes. This is usually only used to optimize routing settings. The default value is 536.
Window W
Set the TCP Window Length of the Connection Based on this route to W bytes. This is usually used only for AX.25 networks and devices that cannot process back-to-back frames.
Irtt I
Set the initial round-trip time of the TCP connection based on this route to I Millisecond (1-12000 ). This is usually only used for the AX.25 network. If this option is omitted, the default value of RFC1122 is 300 ms.
Reject
Set a blocked route to make a route query fail. This is used to shield some networks before using the default route. However, this does not act as a firewall.
Mod, dyn, reinstate
Set a dynamic or changed route. These flags are usually set only by the selector process. This is for diagnostic purposes only,
Dev If
Force the route to be associated with the specified device, because otherwise the kernel will try to detect the corresponding device by itself (usually check the existing route and the specifications of the devices that are added to the route ). You do not need to use it on most normal networks.
If dev If is the last specified option on the command line, you can omit the keyword dev because it is the default value. Otherwise, metric-netmask-gw-dev does not matter.
Example EXAMPLES
Route add-net 127.0.0.0
Add A normal loop interface, which uses the mask 255.0.0.0 (determined by the target address that it is A Class A Network) and associated with the device "lo" (assuming that the device was previously set correctly by ifconfig (8 ).
Route add-net 192.56.76.0 netmask limit 255.0 dev eth0
Add a route entry pointing to network 192.56.76.x to "eth0. The Class C subnet mask is not required because 192. * is a class c ip address. The keyword "dev" can be omitted.
Route add default gw mango-gw
Add a default route (use it if it cannot match other routes ). All groups using this route will be transmitted through the gateway "mango-gw. The device that actually uses this route depends on how it reaches the "mango-gw"-a static route that has previously been set to "mango-gw.
Route add ipx4 sl0
Add a route entry pointing to "ipx4" to the SLIP interface (assuming "ipx4" is the host using the SLIP ).
Route add-net 192.57.66.0 netmask 255.255.255.0 gw ipx4
This command is used to add the gateway ipx4 of the previous SLIP interface to the route of "192.57.66.x.
Route add 224.0.0.0 netmask 240.0.0.0 dev eth0
This command sets the route for all Class D addresses (for multicast) for "eth0. This is the correct configuration line for the multicast kernel.
Route add 10.0.0.0 netmask route 0.0.0 reject
This command sets a blocking route for the private network "10. x.
OUTPUT information OUTPUT
The output information of the kernel routing table is composed of the following columns:
Destination
Target network or host.
Gateway
Gateway address or '*' (if not set ).
Genmask
Subnet Mask of the target network. '127. 255.255.255' is the host, and '0. 0.0.0 'is the default route.
Flags
Possible indications are:
The U (route is up) route is normal.
H (target is a host) host Routing
G (use gateway) uses the indirect routing of the gateway
R (reinstate route for dynamic routing)
D (dynamically installed by daemon or redirect) the route is dynamically created by the selector process or redirection.
M (modified from routing daemon or rederict) The route has been modified by the routing process or redirection.
! (Reject route) blocking Routing
Metric
Distance to the target (usually calculated based on hops ). The new kernel does not use this concept, but the selector process may use it.
Ref
Number of active processes using this route (not used in Linux kernel ).
Use
The number of times the route is queried. Based on the use of-F and-C, this value is the number of loss or sampling of the route cache.
Iface
The API that uses this route to send a group.
MSS
The default maximum packet segment length of the TCP connection based on this route.
Window
The default Window Length of the TCP connection based on this route.
Irtt
The initial round-trip time. The kernel uses it to guess the best TCP protocol parameters without waiting (which may be slow) for a response.
HH (cached only)
Number of ARP records and cached routes that access the hardware header cache for cached routes. If the cached router interface (such as lo) does not require a hardware address, the value is-1.
Arp (cached only)
Update the cache route regardless of the hardware address used.
File FILES
/Proc/net/route 6_route
/Proc/net/route
/Proc/net/rt_cache
Both of them can be shared, but how can we automatically select a line? Currently, some Internet cafes can automatically select lines, and some have to switch manually. I thought of the route table. The destination ip address is the school's wired network card, and all other ip addresses use an unlimited network card. Yes, it is the route command. I checked the related route command online. the specific settings are as follows: tplink 410 static ip address, add the ip address assigned by the school, clone the mac address, enable dhcp, and dmz (do not enable verification .), Set the IP address of the lanport to 192.168.2.1. Because ip192.168.1.1 is required for the wireless network, you can change the IP address to 2.1. Of course, you need to add the account and password of adsl for wireless routing. When dhcp is enabled, ip defaults are set on the lanport, and keys are useless, but mac addresses are limited, prohibit mac access routes from multiple computers in the dormitory.
After the settings are complete, the route table is used, that is, the route command. The Route command is applicable in windows and linux, but there are some minor differences. The following describes my understanding of route. Experts can give you more details. Paste my batch processing first:
Route add 202.206.0.0 mask route 0.0 192.168.2.1
Route add 10.186.0.0 mask route 0.0 192.168.2.1
Route add 10.185.0.0 mask route 0.0 192.168.2.1
Route add 0.0.0.0 mask 0.0.0.0 192.168.1.1
Parameter description: ^ destination ^ mask ^ gateway metric ^ interface
Destination [CIDR block]
Mask [subnet mask]
Gateway [gateway address]
Metric [route hops]
If [port number]
Where:
The [number of Route hops] parameter can be omitted;
When the path to the gateway address is unique, the port number parameter can be omitted. (Because there may be multiple backup paths to the same IP address on a multi-port routing switch device .)
Mask is a keyword and cannot be omitted.
Route add 202.206.0.0 mask route 0.0 192.168.2.1
All ip data packets sent to the CIDR Block 202.206.0.0 are sent by the 192.168.2.1 gateway.
In this way, we can see that the ip segments of some servers in our school are about 202.206.0.0, 10.186.0.0 and 10.185.0.0. In fact, there are other, but I am not using them for the time being, so I didn't add them.
Route add 0.0.0.0 mask 0.0.0.0 192.168.1.1
All ip data packets in other CIDR blocks are sent by 192.168.1.1.
In this way, the batch processing will be run on each sub-machine, and the dual-line Internet access will be automatically selected. I guess the Internet cafes are similar. They can use a dual-wan route. They can add static route tables to routers or servers. Other machines do not need to add route tables, you can automatically access the Internet through two lines. However, the route table of China Telecom Netcom seems to be quite large. I don't know who can share it with me. Haha
There is also the route change command, that is, to change add to change, that is, to change the static route table.
In this way, our goal is to achieve the ability to access out-of-school resources. One computer can also access out-of-school resources through the dial-up program of the school. If he has run the batch processing, you can also use the route change command to change a static route table. Below is a batch post I wrote:
@ ECHO OFF
CLS
Color 0a
ECHO =-= select the service project to be started =-=
ECHO.
ECHO 1 dual-network dual-line, if you do not use elink, choose start!
ECHO.
ECHO 2: Restore elink dialing (1 is selected before, and 2 is selected again now. If no line is selected before, you do not need
Select ECHO and dial up directly)
ECHO.
ECHO 3 resumes dual-network dual-line recovery (previously selected 2 and now reselected back to dual-network dual-line recovery)
ECHO.
ECHO.
SET/p st = enter 1 2 3 or any other key to cancel:
If/I \ "% ST % \" = \ "1 \" goto SERVICE1
If/I \ "% ST % \" = \ "2 \" goto SERVICE2
If/I \ "% ST % \" = \ "3 \" goto SERVICE3
Goto END
: SERVICE1
Route add 202.206.0.0 mask route 0.0 192.168.2.1
Route add 10.186.0.0 mask route 0.0 192.168.2.1
Route add 10.185.0.0 mask route 0.0 192.168.2.1
Route add 0.0.0.0 mask 0.0.0.0 192.168.1.1
: SERVICE2
Route change 0.0.0.0 mask 0.0.0.0 192.168.2.1
: SERVICE3
Route change 0.0.0.0 mask 0.0.0.0 192.168.1.1
: END
In this way, you can freely choose how to access the Internet. In fact, I feel better to use vb to write a small program.
Let's get to the end. Another point is the route add command in linux.
Route 202.206.0.0 netmask 255.255.0.0 gw 192.168.2.1
Okay, write it here. I am not writing well. You may have laughed at it and contributed it to the record. You are welcome to repost it.