How to configure dual Network Card and dual Gateway routing Table in Linux
This article is about how to configure the dual-card and dual-gateway routing table in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Server operating system RedHat linux 9, set up two routing tables
1. Vi / etc/iproute2/rt_tables, add Netcom and Telecom routing tables
251tel Telecom routing Table
252 cnc Netcom routing table
two。 Bind two addresses to the network card for telecom and Netcom lines
Ip addr add 192.168.0.2/24 dev eth0
Ip addr add 10.0.0.2/24 dev eth2
3. Set up the routing tables of Telecom and Netcom respectively
Telecom routing table:
# make sure the local subnet is found
Ip route add 192.168.0..0/24 via 192.168.0.2 dev eth0 table tel
# Internal loopback network
Ip route add 127.0.0.0/8 dev lo table tel
# 192.168.0.1 is the default gateway address of telecom network
Ip route add default via 192.168.0.1 dev eth0 table tel
Netcom line routing table:
# make sure the local subnet is found
Ip route add 10.0.0.0/24 via 10.0.0.2 dev eth2 table cnc
# Internal loopback network
Ip route add 127.0.0.0/8 dev lo table cnc
# 10.0.0.1 is the default gateway of Netcom
Ip route add default via 10.0.0.1 dev eth2 table cnc
4. Telecom and Netcom each have their own routing tables and formulate strategies to route the response packets of 192.168.0.2 and 10.0.0.2 to Netcom's routing table.
Ip rule add from 192.168.0.1 table tel
Ip rule add from 10.0.0.1 table cnc
Thank you for reading! This is the end of the article on "how to configure dual-card and dual-gateway routing tables in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!