Configuring Policy-based Routing for an Edge Instance with Multiple NICs
Scenarios
If an edge instance has multiple NICs, you need to configure policy-based routing for the edge instance so that extension NICs are used for network communications.
Procedure
For a Linux edge instance:
- Add the priority value and name of the route table for each NIC to the /etc/iproute2/rt_tables file (a smaller value represents a higher priority. In this example, 250 and net0 indicate the route table priority and the name of eth0, respectively. 251 and net1 indicate the route table priority and the name of eth1, respectively. If there are multiple NICs, add the route table priority and the name of each NIC one by one).
vi /etc/iproute2/rt_tables
# added for dual net 250 net0 251 net1
- Add routing information of each NIC to the rc.local file.
vi /etc/rc.local
eth0 is used as an example here. If an IPv4 NIC is used, add the following information:
IPv4 address (192.168.0.129), subnet (192.168.0.0/24), gateway (192.168.0.1), and route table added in the preceding step (net0)
# wait for nics up sleep 5 # Add v4 routes for eth0 ip route flush table net0 ip route add default via 192.168.0.1 dev eth0 table net0 ip route add 192.168.0.0/24 dev eth0 table net0 ip rule add from 192.168.0.129 table net0 # Add v4 routes for eth1 ip route flush table net1 ip route add default via 192.168.1.1 dev eth1 table net1 ip route add 192.168.1.0/24 dev eth1 table net1 ip rule add from 192.168.1.138 table net1
- Add the execute permission to the rc.local file.
# chmod +x /etc/rc.local
- Run reboot to restart the edge instance.
- After the restart, check whether the configured routes and route tables take effect.
For IPv4 NICs:
ip rule
ip route show table net0
ip route show table net1

- Specify the source addresses for the test.
For IPv4 addresses:
ping -I 192.168.0.129 xxx
ping -I 192.168.1.138 xxx
For a Windows edge instance:
- Choose Control Panel > Network and Internet > Network Connections. Right-click Local Area Connection 2 and then click Properties.
Right-click to add NICs based on the site requirements. If there are multiple NICs, there will be multiple local area connections. Configure them one by one.
- On the Network tab page, select Internet Protocol Version 4 (TCP/IPv4).
- Click Properties.
- On the General tab page, click Advanced.
- In the IP Settings tab, click Add in the Default gateways area. Figure 1 Advanced TCP/IP settings
- Enter the gateway address of the extension NIC and click Add. Figure 2 TCP/IP Gateway Address
- Click OK.
- Open the command line interface (CLI) of the Windows OS and enter route print to view the policy-based routes.

- Specify the source addresses for the test.
ping -S 192.168.0.129 xxx
ping -S 192.168.1.138 xxx
Related Operations
Accessing the Internet using an EIP bound to an extension NIC
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.