Help Center> Intelligent EdgeCloud> User Guide> Common Operations> Configuring Policy-based Routing for an Edge Instance with Multiple NICs

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:

  1. 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 

  2. 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

  3. Add the execute permission to the rc.local file.

    # chmod +x /etc/rc.local

  4. Run reboot to restart the edge instance.
  5. 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

  6. 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:

  1. 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.

  2. On the Network tab page, select Internet Protocol Version 4 (TCP/IPv4).
  3. Click Properties.
  4. On the General tab page, click Advanced.
  5. In the IP Settings tab, click Add in the Default gateways area.

    Figure 1 Advanced TCP/IP settings

  6. Enter the gateway address of the extension NIC and click Add.

    Figure 2 TCP/IP Gateway Address

  7. Click OK.
  8. Open the command line interface (CLI) of the Windows OS and enter route print to view the policy-based routes.

  9. Specify the source addresses for the test.

    ping -S 192.168.0.129 xxx

    ping -S 192.168.1.138 xxx