Profile

Paul Annesley This is the personal website of Paul Annesley, senior developer at 99designs in Melbourne, Australia. You can follow Paul on Twitter.

Recent Bookmarks

  • toto » Tiny blog engine in Ruby and Rack, uses flat git-managed content files containing YAML & ERB/Markdown, handles comments via disqus, leaves caching to HTTP.
  • Machinarium » A puzzle point-and-click adventure game with a nice ambient soundtrack and a Oddworld: Abe's Oddysee feel about it. Implemented in flash, free demo.
  • Semantic Versioning » Simple version number specification for systems which expose a public API. The format is major.minor.patch (e.g. 3.0.12); major indicates backwards incompatible, minor indicates backwards compatible, and 0.x.x indicates rapid development.
  • The Go Programming Language » New programming language from Google: performance like C, dynamic like Python, concurrent like Erlang.
  • node.js » Event driven network IO for V8 JavaScript.
  • v8 JavaScript Engine » Google's JavaScript engine as seen in Chrome, runs standalone or embedded in C++
  • jaml - GitHub » Jaml tries to emulate Ruby’s Haml library, making it easy to generate HTML in your JavaScript projects.
  • proxymachine - GitHub » Awesome looking Ruby/EventMachine TCP proxy from GitHub that does content-based routing to a backend. Opens a proxy to a backend once the read buffer contains enough information for a ruby block to return the desired backend address.

People

  • James Annesley » Maker and purveyor of fine jazz saxophone music in Melbourne, Australia

Conflict free DNS and routes with multiple DHCP interfaces

27 October 2009

The Problem

Running DHCP on two or more network interfaces inevitably leads to conflicting or unpredictable DNS and default route settings.

For development at home and work, I use an Ubuntu virtual machine running on Mac OS. To ensure I have a predictable IP address regardless of what network I'm on, the VM primary network interface is NATed, so it gets an IP address from VMware's DHCP server. To let my co-workers access HTTP on my virtual machine, I have a second network interface which is bridged

The biggest symptom of the problem is complete loss of connectivity when I switch between home and office, and the default route from the previous location is retained.

The Solution That Should Work

DHCP client configuration lets you specify which details you want to request from the DHCP server.

The request statement

request [ option ] [, ... option ];

The request statement causes the client to request that any server responding to the client send the client its values for the specified options. Only the option names should be specified in the request statement - not option parameters. By default, the DHCP server requests the subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, nis-domain, nis-servers, and ntp-servers options.

So it should be possible to omit 'routers' and 'domain-name-servers' from the 'request' statement of the bridged interface, and all should be good. However, it seems that some DHCP servers (like in my Linksys router at home) send a 'router' anyway, and the DHCP client respects it despite not having requested it.

The Solution That Does Work

The solution that seems to work reliably is to write a simple dhclient-enter-hook to unset any unwanted details before they are processed.


# /etc/dhcp3/dhclient-enter-hooks.d/bridged-eth1

if [ "$interface" = eth1 -a -n "$new_routers" ]; then
        echo Discarding eth1 routers: $new_routers
        unset new_routers
fi
if [ "$interface" = eth1 -a -n "$new_domain_name_servers" ]; then
        echo Discarding eth1 dns servers: $new_domain_name_servers
        unset new_domain_name_servers
fi