1

I have been reading through man dhclient and man dhclient.conf and cannot find a way to get it to ignore an interface. As in, pretend it does not exist.

I do not want to shut any interface down. I just want dhclient to establish a lease on a specific interface and leave the others alone.

I tried this as a very simple .conf file that I hoped would work to get it to stop paying attention to iface2.

interface "iface1" {

}

interface "iface2" {
        reject 192.168.0.0/16
        reject 10.0.0.0/8
}

The point here is to allow it to engage in default behaviour with iface1, but ignore iface2.

But at this point I am just making stupid guesses -- the manual, as far as I can tell, says absolutely nothing about disabling or ignoring interfaces, as if this were something ridiculous or impossible. However, it seems like a very simple task to me and presumably I have misinterpreted or just plain missed something somewhere.

The above conf (invoked dhclient -v -d -cf that.conf) does work to connect to and obtain a lease from iface1, but it then continues endlessly to post DCHPDISCOVER, etc, and failures to due with iface2. The reason I want this to stop is I want to try and do something unrelated with iface2 and if there are problems, I want to be sure it is not because of dhclient.

Note that specifying the interface on the command line (dhclient -v -d iface1) results in identical behaviour.

1

Okay, stupid me. The solution is to simply leave the inteface unmentioned in the conf file:

interface "iface1" {

}

It now just gets a lease on iface1 and that's it.

Note again this is not the behaviour I get from dhclient iface1, in which case it first acquires a lease on iface1 but then continues to keep paying attention to everything else -- although there was no pre-existing dhclient.conf anywhere and /etc/dhcp was empty.

  • Leaving an interface unmentioned doesn't work. From man page Note well: ISC dhclient only maintains one list of interfaces, which is either determined at startup from command line arguments, or otherwise is autodetected. – Kaz Feb 5 '18 at 21:21
0

If you have iface1 and iface2 but only want dhclient to get an IP address etc for iface1, then why not just run: dhclient [other-args] iface1?

By providing it with one or more interface name(s) on the command-line, it will only use that interface or interfaces.

see man dhclient for details.

  • As mentioned in the question and my answer this is not the observed the behavior. This is what I assumed (and have assumed for a long time, in fact), but I noticed it was not the case when I used a (usb tether) interface that doesn't normally exist ("iface1"). dhclient -v iface1 (how I normally connect) worked fine, then when I was trying to set up iface2 as an AP (wlan, which is what I commonly use as a client), I noticed in syslog repeated statements from dhclient about the wlan iface2 I did not want it to use. I shut it down and ran it in the foreground (-d) and low and behold, – goldilocks Mar 3 '16 at 7:44
  • that's what it does. I.e., dhclient -v -d iface1 does a discover and negotiation with iface1, but then endlessly reports messages about iface2 as well (I presume it has old leases related to this interface wherever). The only way I could stop this was by specifying a conf (-cf) which explicitly refers only to iface1. – goldilocks Mar 3 '16 at 7:46
  • sorry, i had stopped reading before your last paragraph. should have read to the end. I would recommend submitting a bug report because the documentation clearly shows that one or more interfaces can be supplied on the command-line, and there's really no point doing that except to limit which interfaces it works on. – cas Mar 3 '16 at 7:46
  • does it do the same if you clear out your old leases file? – cas Mar 3 '16 at 7:47
  • 1
    at least you have relevant info for your bug report - dhclient ignores interface restriction on command line if an old leases file mentions another interface. – cas Mar 3 '16 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.