Linux – Openwrt two nic on the same vlan instead of alias

interfacelinuxnetworkingopenwrtrouting

I have a TP-Link WR1043ND with 1 wan and 1 lan cables attached. The lan cable currently have 2 ips of two different network, using an alias. The two networks share the same switch.

I'd like the router to forward between the two.
Currently the routers sends ICMP redirect to the first network telling the clients to go to the second network directly, which is impossible.

Could I create a second virtual nic in the same vlan and assign it the IP on the second network?

Thanks!

Best Answer

This is not specific to OpenWRT but works with any Linux 2.6 - based distro. Just disable the sending of ICMP redirects for your aliased interface (assumed eth0 for the code examples):

echo "0" > /proc/sys/net/ipv4/conf/eth0/send_redirects

which would be effective until re-setting or reboot. To make the setting permanent add this line to /etc/sysctl.conf:

net.ipv4.conf.eth0.send_redirects = 0

and run sysctl -p to reload the configuration.