OK6232 Linux 6.1.33 Dual-NIC Same-Subnet Policy Routing Configuration
Background
In a Linux system, when two network interface cards (NICs) are configured with IP addresses within the same subnet, the default routing table generally utilizes only the most recently activated NIC interface. Consequently, the other NIC may be unable to communicate as intended. To address this issue, policy routing can be implemented. This allows each network interface to operate independently, effectively preventing routing conflicts.
Kernel configuration
First, confirm that policy routing support is enabled in the kernel. By default, this feature is not activated, so manual configuration is required:
Access the kernel source directory at /62xx/OK62xx-linux-sdk/OK62xx-linux-kernel/ and run the following command:
forlinx@ubuntu:~/62xx/OK62xx-linux-sdk/OK62xx-linux-kernel$ . /opt/arago-2023.04/environment-setup-aarch64-oe-linux forlinx@ubuntu:~/62xx/OK62xx-linux-sdk/OK62xx-linux-kernel$ make menuconfig
Based on the following screenshot, locate the policy routing configuration path.
Select the indicated option with the arrow, press the Y key to compile it into the kernel.
Then select Save.
Click OK.
Repeatedly press ESC to exit
Next, navigate to the directory ~/62xx/OK62xx-linux-sdk and begin compiling the kernel based on the core board parameters:
forlinx@ubuntu:~/62xx/OK62xx-linux-sdk$ sudo ./build.sh kernel hsfs 2g
Enter N when prompted.
If the following message appears, press and hold the Enter key:
Development Board Configuration
Once compilation is successful, move the Image file from the /62xx/OK62xx-linux-sdk/images directory to the /boot/ directory on the development board.
Execute
root@OK62xx:/# sync root@OK62xx:/# reboot
Configuring Routing Tables
After rebooting, open the routing table configuration file /etc/iproute2/rt_tables:
root@OK62xx:/# vi /etc/iproute2/rt_tables
Add two routing tables:
100 eth0table
200 eth1table
Save.
Configuring Policy Routing
Next, set up routing policies for each network interface. Assuming eth0 has IP address 172.20.2.131 and eth1 has 172.20.2.132, execute the following commands to configure routing policies:
Add routing policies for eth0:
root@OK62xx:/# ip route add 172.20.2.0/24 dev eth0 table eth0table root@OK62xx:/# ip route add default via 172.20.2.254 dev eth0 table eth0table root@OK62xx:/# ip rule add from 172.20.2.131 table eth0table
1. First command: Specify that network segment 172.20.2.0/24 should use eth0 as its egress interface.
2. Second command: Set the default gateway for external network access (adjust gateway IP as needed).
3. Third command: Route all traffic from IP 172.20.2.131 through routing table eth0table.
Add routing policies for eth1:
root@OK62xx:/# ip route add 172.20.2.0/24 dev eth1 table eth1table root@OK62xx:/# ip route add default via 172.20.2.254 dev eth1 table eth1table root@OK62xx:/# ip rule add from 172.20.2.132 table eth1table
Test
At this point, you can verify whether the configuration is successful by using the ping command on a PC:
When the Ethernet cable is connected to eth0, you should be able to reach 172.20.2.131. When connected to eth1, you should be able to reach 172.20.2.132.
Both IP addresses should be ping-able.
Persistent Configuration
Policy routing configurations, like network settings, are not retained after reboot—they need to be automatically applied on startup. Therefore, a service that runs at boot must be added.
Create a startup service for this purpose.
root@OK62xx:/# vi /etc/systemd/system/persistent-routes.service
Add the followings:
[Unit] Description=Persistent Static Routes and Rules After=network-online.target Wants=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/persistent-routes.sh [Install] WantedBy=multi-user.target
Add script.
root@OK62xx:/# vi /usr/bin/persistent-routes.sh
Add the followings:
#!/bin/sh sleep 5 # Add Routes and Rules ip route add 172.20.2.0/24 dev eth1 table eth1table ip route add default via 172.20.2.254 dev eth1 table eth1table ip rule add from 172.20.2.132 table eth1table ip route add 172.20.2.0/24 dev eth0 table eth0table ip route add default via 172.20.2.254 dev eth0 table eth0table ip rule add from 172.20.2.131 table eth0table
Give permission to the script:
root@OK62xx:/# chmod 777 /usr/bin/persistent-routes.sh
Enable the service
root@OK62xx:/# systemctl enable persistent-routes.service
This way, the configuration is automatically applied upon every system startup.
Summary
Through the steps above, dual network interfaces in the same subnet have been successfully configured, with policy routing avoiding routing conflicts. After configuration, both network interfaces can operate stably for network debugging or data transmission, providing reliable support for high‑availability embedded applications.
Through the steps above, dual network interfaces in the same subnet have been successfully configured on the OK6232 development board, with policy routing effectively avoiding routing conflicts. After configuration, both network interfaces of the FET6232-C core board (based on the TI AM62x processor) can operate stably for network debugging or data transmission, providing reliable support for high‑availability embedded applications developed by Forlinx Embedded.


