I have a multihomed host with 2 Ethernet interfaces and a usb-connected cell modem. The Ethernet interfaces are configured in a typical way on the main routing table, with only one default route assigned to one of them.
[/]# ip route show table main default via 192.168.4.1 dev eth0 metric 50 192.168.2.0/24 dev eth1 scope link src 192.168.2.10 192.168.4.0/22 dev eth0 scope link src 192.168.4.73
There is another default route assigned to the cell interface on a separate "usbcell" routing table.
[/]# ip route show table usbcell default via 10.26.128.2 dev usbcell src 10.26.128.1
An IP rule directs all packets marked with value 0x100 to use the usbcell routing table. These packets are marked at the socket level within an application. We also add source based routing rule to prevent reverse path filtering from dropping usbcell traffic.
[/]# ip rule 0: from all lookup local 97: from 10.26.128.1 lookup usbcell 100: from all fwmark 0x100 lookup usbcell 32766: from all lookup main 32767: from all lookup default
The Cell interface has an IP, netmask and gateway provided dynamically by the modem hardware. This subnet is not owned by the carrier or us, so I would like to prevent collisions with any other networks connected to the Ethernet ports. This should be easy since the cell interface is on a separate routing table. But, unfortunately, whenever the cell interface is brought up via ifup, a local route to the interface is added to the main table. This routes all packets bound for that subnet to the cell interface instead of just the marked ones. If I remove the local route, it works as expected.
Main table when usbcell is up:
[/]# ip route show table main default via 192.168.4.1 dev eth0 metric 50 10.26.128.0/17 dev usbcell scope link src 10.26.128.1 ## How do I prevent this? ## 192.168.2.0/24 dev eth1 scope link src 192.168.2.10 192.168.4.0/22 dev eth0 scope link src 192.168.4.73
Is there a way of preventing this local route from being added to the main table when the usbcell interface is brought up?
10.26.128.0/17 dev usbcell scope link src 10.26.128.1
In this example, I want unmarked packets bound for the subnet 10.26.128.0/17 to be routed out the main table default route (to eth0).