If eth0 is 192.168.10.123/255.255.255.0 and eth1 is 192.168.255.231/255.255.255.0, the command format is as follows:
# Route add-net 192.168.10.0 netmask 255.255.255.0 dev eth0
# Route add-net 192.168.20.0 netmask 255.255.255.0 dev eth1
The above Command sends the IP packet sent to the 192.168.10.0 network segment to eth0 for forwarding, And the IP packet of the 192.168.20.0 network segment to eth1 for forwarding. If a package may be sent to another destination IP address, you may want to set a "Default Gateway ":
# Route add default gw 192.168.10.1
The preceding command forwards all packets sent to other destination IP addresses to 192.168.10.1, the rule on How to forward the address to 192.168.10.1 has been defined in the first command just now (forwarded from eth0 ). In general, the default gateway has been automatically set, and you do not need to set it again. You can use the route command to add the-n parameter for inspection.
To delete a certain entry, the command format is:
# Route del-net 192.168.10.0 netmask 255.255.255.0
One idea during configuration is to route the 192.168.10.0 CIDR block to eth0 and 192.168.20.0 CIDR block to eth1, and then set the default route. Another idea is to specify only one of them, and then route the default 0.0.0.0 to the other. In fact, the effect is the same, that is, two styles.