You are not logged in.

#1 2020-04-07 22:43:55

yorkz
Member
Registered: 2020-03-22
Posts: 32

[SOLVED] Have dhcpcd obtain IP only if wire is connected

My laptop has both a wired and a wireless NIC, and I'm using dhcpcd on the wired interface. Everything work well as long as the Ethernet cable always connects. However, if I plug the cable out (to use the wireless NIC) and reboot, the rebooting will take a lot longer because dhcpcd tries to obtain the IP address on a disconnected line. My question is, how can I have dhcpcd obtain IP only if the cable is connected? Thanks in advance.

Last edited by yorkz (2020-04-08 16:28:31)

Offline

#2 2020-04-07 22:48:57

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Offline

#3 2020-04-07 23:27:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

2ManyDogs, the link you pointed to starts with this:

wiki wrote:

Tip: dhcpcd provides the same feature out of the box.

The problem is not dhcpcd, but rather the (frankly silly) default systemd service that is packaged with it.  The solution is in the wiki page for dhcpcd.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2020-04-08 00:51:34

yorkz
Member
Registered: 2020-03-22
Posts: 32

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Thank you 2ManyDogs. "ifplugd" works, but I found that I had to write the ifplugd.action script to call "dhcpcd" on the "up" event.
Thank you Trilby, the "dhcpcd drop-in file" solution is simple, clean, and works perfectly!

Offline

#5 2020-04-08 13:14:19

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

#6 2020-04-08 14:40:00

yorkz
Member
Registered: 2020-03-22
Posts: 32

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Thanks 2ManyDogs for reminding me of marking this thread as [SOLVED]. I'll definitely do that but I've noticed a "side effect" of not having dhcdcd wait for a successful connection. The problem is that the daily pkgfile database update failed the first time the system booted in the morning:

systemd[1]: Failed to start pkgfile database update.

I enabled the pkgfile database update by:

  sudo systemctl enable pkgfile-update.timer

after I installed pkgfile. This isn't a big deal though, but would be best if there's a simple way to address it.

Last edited by yorkz (2020-04-08 14:41:36)

Offline

#7 2020-04-08 14:46:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

That's a seperate issue.  You could adjust the timer to wait with an OnBootSec, or make it depend on dhcpcd.  But really, why are you using pkgfile at all - I just checked and was surprised that it's still in the repos.  Pacman has the -F flag that now does the same thing.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2020-04-08 15:39:04

yorkz
Member
Registered: 2020-03-22
Posts: 32

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Trilby wrote:

That's a seperate issue.

Agreed, I was just too lazy to start a brand new thread, sorry about that.

Trilby wrote:

You could adjust the timer to wait with an OnBootSec, or make it depend on dhcpcd.

Thanks for the suggestion.

Trilby wrote:

Pacman has the -F flag that now does the same thing

I'm not sure whether "pacman -F" is a full replacement of pkgfile because with pkgfile one can search which package owns a file without having the package installed. However, according to the pacman manpage:

-F, --files
    Only packages that are part of your sync databases are searched.

My understanding is that the package has to be installed first. Please correct me if my understanding is wrong.

Last edited by yorkz (2020-04-08 15:41:46)

Offline

#9 2020-04-08 16:26:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Your understanding is wrong.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2020-04-08 16:27:38

yorkz
Member
Registered: 2020-03-22
Posts: 32

Re: [SOLVED] Have dhcpcd obtain IP only if wire is connected

Trilby wrote:

Your understanding is wrong.

I realized that after some searching, thanks.

Offline

Board footer

Powered by FluxBB