Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Victor Sudakov
Greg Wooledge wrote:
> On Wed, Aug 26, 2020 at 10:56:30AM +0700, Victor Sudakov wrote:
> > I've made some changes to /etc/dhcp/dhclient.conf, now I need to make
> > dhclient reread it (and apply the changes to /etc/resolv.conf).
> 
> There is nothing you can put in dhclient.conf that will successfully
> prevent dhclient from fucking up your resolv.conf file in the general
> case.  

Well, I don't quite agree with you. The append, prepend and supersede
options can be quite useful.

> (You might be lucky enough that it works on *one* network, but
> even then, why take the chance?)
> 
> Please see  for your options.

Yes, my case is mentioned there in the "Modifying /etc/dhcp/dhclient.conf" 
paragraph.
Sadly, this article does not mention how to restart dhclient gracefully.

> 
> As far as "re-reading" goes, what you want to do is bring the interface
> down and back up.
> 
> ifdown yourifname
> ifup yourifname

I've found out that running `systemctl restart networking` is sufficient,
simple and safe. I've modified 3 remove hosts already without issues.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Greg Wooledge
On Wed, Aug 26, 2020 at 10:56:30AM +0700, Victor Sudakov wrote:
> I've made some changes to /etc/dhcp/dhclient.conf, now I need to make
> dhclient reread it (and apply the changes to /etc/resolv.conf).

There is nothing you can put in dhclient.conf that will successfully
prevent dhclient from fucking up your resolv.conf file in the general
case.  (You might be lucky enough that it works on *one* network, but
even then, why take the chance?)

Please see  for your options.

As far as "re-reading" goes, what you want to do is bring the interface
down and back up.

ifdown yourifname
ifup yourifname

Obviously you can't do that in two steps if the machine is remote.  If
it's a remote machine, you'll need to do something clever-ish, like

ifdown yourifname; sleep 2; ifup yourifname

And *do not* make any mistakes.  (Doing it inside screen or tmux would
also be wise, just in case you lose the ssh connection during those
few seconds.)

Another alternative would be simply to reboot.



Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Victor Sudakov
Reco wrote:
> 
> On Wed, Aug 26, 2020 at 10:56:30AM +0700, Victor Sudakov wrote:
> > There seems to be no dhclient service in systemd, and I don't find
> > any info about signalling dhclient with "kill -HUP" etc.
> 
> There is no need for "dhclient" service in systemd, as there's
> "networking" service for that. Restarting the latter is probably a bad
> idea in your case.

Not that bad, and actually thank you for this idea. I've just tried 
`systemctl restart networking` on a host I have emergency console access
to, and it went well: the host became inaccessible for 4-5 seconds and
then got back online, and even TCP connections (including my ssh
session) were not dropped.

> 
> 
> > "dhclient -x" or "dhclient -r" bring the network down (I've actually
> > confirmed that on a test host), and I loathe to risk it on a remote box.
> 
> As they should. Both "-x" and "-r" run dhclient scripts before dhclient
> exists, and this involves deconfiguring an appropriate network
> interface.
> 
> 
> > A reboot seems too radical.
> > 
> > Any ideas please?
> 
> Try this (note to the certain list readers - it's dangerous, do not try
> it at home unless you have a console access):
> 
> # ip -o a l dev eth0
> 2: eth0inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0...
> ...
> # pgrep -fa dhc
> 355 /sbin/dhclient -4 -v -i -pf /run/dhclient.eth0.pid ...
> # pkill -9 -f dhclient
> # ip -o a l dev eth0 # note that the IPs stay
> 2: eth0inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0...
> ...
> # ifup --force eth0
> Internet Systems Consortium DHCP Client 4.4.1 ...
> 
> Basically, by sending SIGKILL to dhclient you leave your current
> interface configuration as is, and by running dhclient again (via ifup
> in this case) you apply your dhclient.conf changes.

Thanks, Reco, if ever `systemctl restart networking` fails me, I'll do
this manual thing.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Reco
Hi.

On Wed, Aug 26, 2020 at 10:56:30AM +0700, Victor Sudakov wrote:
> There seems to be no dhclient service in systemd, and I don't find
> any info about signalling dhclient with "kill -HUP" etc.

There is no need for "dhclient" service in systemd, as there's
"networking" service for that. Restarting the latter is probably a bad
idea in your case.


> "dhclient -x" or "dhclient -r" bring the network down (I've actually
> confirmed that on a test host), and I loathe to risk it on a remote box.

As they should. Both "-x" and "-r" run dhclient scripts before dhclient
exists, and this involves deconfiguring an appropriate network
interface.


> A reboot seems too radical.
> 
> Any ideas please?

Try this (note to the certain list readers - it's dangerous, do not try
it at home unless you have a console access):

# ip -o a l dev eth0
2: eth0inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0...
...
# pgrep -fa dhc
355 /sbin/dhclient -4 -v -i -pf /run/dhclient.eth0.pid ...
# pkill -9 -f dhclient
# ip -o a l dev eth0 # note that the IPs stay
2: eth0inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0...
...
# ifup --force eth0
Internet Systems Consortium DHCP Client 4.4.1 ...

Basically, by sending SIGKILL to dhclient you leave your current
interface configuration as is, and by running dhclient again (via ifup
in this case) you apply your dhclient.conf changes.

Reco



Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Victor Sudakov
Claudio Kuenzler wrote:
> On Wed, Aug 26, 2020 at 5:56 AM Victor Sudakov  wrote:
> 
> > Dear Colleagues,
> >
> > I've made some changes to /etc/dhcp/dhclient.conf, now I need to make
> > dhclient reread it (and apply the changes to /etc/resolv.conf).
> >
> > There seems to be no dhclient service in systemd, and I don't find
> > any info about signalling dhclient with "kill -HUP" etc.
> >
> > "dhclient -x" or "dhclient -r" bring the network down (I've actually
> > confirmed that on a test host), and I loathe to risk it on a remote box.
> > A reboot seems too radical.
> >
> > Any ideas please?
> >
> 
> A simple "dhclient" as root (or "sudo dhclient") without parameters should
> be enough.
> In syslog you should be able to see something like this afterwards:

Not actually. If you look at `ps` output after "sudo dhclient", you'll
notice that you now have 2 dhclients running in the background, the old
one is still there and the new one has been added. And they both will
race to rewrite your /etc/resolv.conf.

Try it out.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: How to make dhclient reread its config? (Debian 10)

2020-08-26 Thread Claudio Kuenzler
On Wed, Aug 26, 2020 at 5:56 AM Victor Sudakov  wrote:

> Dear Colleagues,
>
> I've made some changes to /etc/dhcp/dhclient.conf, now I need to make
> dhclient reread it (and apply the changes to /etc/resolv.conf).
>
> There seems to be no dhclient service in systemd, and I don't find
> any info about signalling dhclient with "kill -HUP" etc.
>
> "dhclient -x" or "dhclient -r" bring the network down (I've actually
> confirmed that on a test host), and I loathe to risk it on a remote box.
> A reboot seems too radical.
>
> Any ideas please?
>

A simple "dhclient" as root (or "sudo dhclient") without parameters should
be enough.
In syslog you should be able to see something like this afterwards:

Aug 26 06:10:41 mailtest dhclient[899]: DHCPDISCOVER on eth0 to
255.255.255.255 port 67 interval 7
Aug 26 06:10:41 mailtest dhclient[899]: DHCPOFFER of 192.168.15.23 from
192.168.15.1
Aug 26 06:10:41 mailtest dhclient[899]: DHCPREQUEST for 192.168.15.23 on
eth0 to 255.255.255.255 port 67
Aug 26 06:10:41 mailtest dhclient[899]: DHCPACK of 192.168.15.23 from
192.168.15.1
Aug 26 06:10:41 mailtest dhclient[899]: bound to 192.168.15.23 -- renewal
in 73845 seconds.


How to make dhclient reread its config? (Debian 10)

2020-08-25 Thread Victor Sudakov
Dear Colleagues,

I've made some changes to /etc/dhcp/dhclient.conf, now I need to make
dhclient reread it (and apply the changes to /etc/resolv.conf).

There seems to be no dhclient service in systemd, and I don't find
any info about signalling dhclient with "kill -HUP" etc.

"dhclient -x" or "dhclient -r" bring the network down (I've actually
confirmed that on a test host), and I loathe to risk it on a remote box.
A reboot seems too radical.

Any ideas please?

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature