how to add an network interface to a specific routing table in dhcp mode

Latest response

I do have a host with 3 interfaces. All have to be configured via dhcp.
But this results in three different default gateways to be added.
How to configure the different interfaces that the routing data from dhcp are added to the correct routing table
eth0 -> rt_eth0 (or default)
eth1 -> rt_eth1
eth2 -> rt_eth2


The "correct" way to solve this is not to supply a Gateway DHCP option from the DHCP servers you don't want to be the gateway. Theoretically what you're saying is "two of my three DHCP servers are misconfigured".

However it's not always that easy. Perhaps other clients on those subnets do need a default gateway.

If using the network scripts, you could write a dhclient-up-hook which deletes the default route the DHCP server just supplied.

NetworkManager also has two connection properties ipv4.ignore-auto-routes and ipv4.never-default which you could play with and see if they work for you.

why there should be misconfigured. There are three different networks with a huge network cloud in the back yard so its not wrong to configure these defaults per interface.... (Any how its a Tier 1 customer network implementation request and not my idea) NetworkManager is a security topic so its not available. Therefore I'll stick to the dhclient hook script... thanks for pointing towards this ... Lets see if I can use this for our targets ( Customer doesn't tell us all about their implementations ... for what ever reason) Thanks I'm a bit suprised that the network-script part doesnt support multiple routing tables or tables per IF

It's a "misconfiguration" as the ideal way to design a network is to have one gateway. However as I guessed and you confirmed, the reality is more complex than the "correct" theory :)

The network-scripts do support policy routing in multiple tables, but routes inserted by DHCP are separate to routes inserted by the network-scripts.