Re: Using different hostnames on different interfaces (with dhclient)



On Tue, 2012-01-24 at 11:25 +0200, Stefan Puiu wrote:
> Hi and thanks for the reply.
> 
> On Mon, Jan 23, 2012 at 10:48 PM, Dan Williams <dcbw redhat com> wrote:
> >> I'm using Ubuntu 11.04 at work and I have 2 NICs, each connected to a
> >> separate subnet. Only one of the subnets is accessible when I VPN to
> >> work, so I thought it would be cool to be able to use different
> >> hostnames for each interface. I tried the following in
> >> /etc/dhcp/dhclient.conf:
> >>
> >> interface "eth4" {
> >>    send host-name "host2";
> >> }
> >>
> >> interface "eth5" {
> >>    send host-name "host1";
> >> }
> >
> > At the moment NM allows the dhclient hostname to be specified in two
> > ways:
> >
> > 1) via the NM connection configuration
> > 2) via an interface-specific dhclient config file
> > like /etc/dhcp/dhclient-<iface>.conf
> >
> > So we could add support for the combined dhclient I suppose, making sure
> > to only use stuff for the right interface.  It's just not implemented at
> > this time.  If you split the config out into separate per-interface
> > config files in the same location, it should work.
> 
> I tried the following:
> $ cat /etc/dhcp/dhclient-eth4.conf
> 
> send host-name "host2";
> 
> $ cat /etc/dhcp/dhclient-eth5.conf
> send host-name "host1";
> 
> However, I still get the IP from eth4 mapped to host1.
> 
> In /var/run/nm-dhclient-eth4.conf I see:
> 
> send host-name "host1"; # added by NetworkManager
> 
> While nm-dhclient-eth5.conf doesn't have any "send host-name" directive.
> 
> What would option 1 involve?

So it looks like NM will use the system hostname if the connection
doesn't provide one (ie, option #1), overriding the send-hostname from
the config file.  Which kinda sucks, I wasn't expecting that, but due
some internal architecture we can't distinguish between the system
hostname and the one from the connection config when DHCP is being
started.  That's fixable though and we should do it; the goal is for
options in the dhclient config files to override the system hostname
(but not configuration hostname as specified below).

For option 1, if your connection is specified using keyfiles (ie, it's
in /etc/NetworkManager/system-connections you can add
"dhcp-send-hostname=<desired hostname>" key to the [ipv4] block and that
should work.

Dan





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