[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Stop dhclient from adding a default gateway



Hello,

I have a Debian Lenny box with two NICs, eth0 and eth1. eht1 is a trunking interface and can be put onto any VLAN. Whenever eth1 is put onto a VLAN, I want it to get an address from DHCP but I do *not* want it to set a default gateway.

I set up a definition for each interface in dhclient.conf and explicitly requested everything except "routers". Here's an example using the interface for VLAN 52:

interface "vlan52" {
request subnet-mask, broadcast-address, time-offset, domain-name, domain-name-servers, host-name;
}

I deleted everything else from the config file, so it's literally just one big list of interface definitions like the one above. I also set up two shell scripts per VLAN, one to set up a static route and the other to delete the route, and set these scripts to run as post-up/pre-down commands for the respective VLAN interface in /etc/network/interfaces, like so:

# VLAN 52 - Library
iface vlan52 inet dhcp
        vlan_raw_device eth1
        post-up /etc/network/scripts/vlan52_add_route
        pre-down /etc/network/scripts/vlan52_del_route

The scripts work and I get the static route, but I still get a default route as well:

# ifup vlan52
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 52 to IF -:eth1:-
Internet Systems Consortium DHCP Client V3.1.2
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/vlan52/00:0d:56:f0:33:5c
Sending on   LPF/vlan52/00:0d:56:f0:33:5c
Sending on   Socket/fallback
DHCPDISCOVER on vlan52 to 255.255.255.255 port 67 interval 5
DHCPOFFER of 10.5.2.176 from 10.5.2.1
DHCPREQUEST of 10.5.2.176 on vlan52 to 255.255.255.255 port 67
DHCPACK of 10.5.2.176 from 10.5.2.1
bound to 10.5.2.176 -- renewal in 107356 seconds.

# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface 10.5.2.0 10.5.2.1 255.255.255.0 UG 0 0 0 vlan52 <-- STATIC ROUTE SET BY THE POST-UP SCRIPT 10.5.2.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan52 <-- DEFAULT ROUTE ADDED BY DHCP! 10.3.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0 0.0.0.0 10.3.1.1 0.0.0.0 UG 0 0 0 eth0

Any help would be greatly appreciated.

    Thanks!
    Dave

--

Dave Parker
Systems Administrator
Utica College
Integrated Information Technology Services
(315) 792-3229
Registered Linux User #408177


Reply to: