# Multihomed system, two VLANs. How ignore one default gateway

## marsark

Hi, i have a box which is connected via eth0 to two tagged vlans. There is a DHCP server in each vlan which provides IP address and also default gateway. This is a problem. When net.eth0 script is finished I have two default gateway rules in route table. How can I set one vlan to ignore default gw from server and accept only IP address and mask?

Here is detail of my /etc/conf.d/net

```

config_eth0="null"                                                                                                                                                                          

                                                                                                                                                                                            

vlans_eth0="4 17"

config="set_name_type VLAN_PLUS_VID_NO_PAD"

config_vlan4="dhcp"

config_vlan17="dhcp"

```

Thanks

----------

## erik258

I think what you want to do is to disable the gateway part of DHCP in one of your dhcp client configurations.  IF you're using dhcpcd, you can use something like this:

dhcpcd_vlan17="-G -C resolv.conf"

This also stops from rewriting resolv.conf with the DNS from this vlan; you probably don't want both rewriting resolv.conf I'd imagine.

----------

## marsark

Actually, I am using dhclient from dhcp package, because I also need DHCP server. I have discovered option nogateway in dhclient-script. I have found some patch in bug 265531.

----------

## gerdesj

You may find value in keeping both default gateways provided that both actually are default gateways.  By a proper default gateway I mean that you can get to all destinations that you need to via both routers.

If not then you'll need to remove the unusable router.

There is no harm in having two routes to 0.0.0.0 (ie default gateway).  You could set a higher metric on the less desirable route:

metric_vlan4="1"

metric_vlan7="2" 

Verify that this works with #ip r.  With that packets will route over vlan4's router unless the vlan interface is unavailable in which case it will use vlan7.  Note that this will not automatically failover if the interface is available but the gateway is not.  For that you'll need something to ping the routers and fix up the routing tables.

You may also want to investigate a router such as Quagga to run on this host which can then fix up routing tables automatically for you and can detect when the next hop has died on one interface.  That might be overkill or a good exercise in learning ...

Cheers

Jon

----------

