# wpa_supplicant + dhcp - dhcpcd doesn't start

## replicant1

I am configuring a laptop for an 802.1x wired authentication. I am having issues with getting an ip address on startup. wpa_supplicant runs and authenticates against the radius server successfully, but the interfaces doesn't acquire an ip address. I have to run dhcpcd manually and then my machine gets assigned an ip address. After that, everything works as expected. 

I'd like to get dhcp working automatically, but I am not sure what to do. dhcpcd is not in /etc/init.d and I cannot add it via rc-update add. I get an error message stating the service dhcpcd does not exist. Then I read that I should not have dhcpcd running as a service? I'd like some help on getting dhcp working automatically when the wired interface authenticates.

Here are the configs.

/etc/conf.d/net

```

config_if0="dhcp"

dhcp_if0="release nonis"

modules_if0="wpa_supplicant netplugd"

wpa_supplicant_if0="-Dwired -c /etc/wpa_supplicant/wpa_supplicant_wired.conf"

```

/etc/wpa_supplicant/wpa_supplicant_wired.conf

```

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

eapol_version=1

ap_scan=0

fast_reauth=1

network={

    key_mgmt=WPA-EAP

    eap=TLS

    identity="Replicant"

    ca_cert="/home/replicant/Certs/RootCA.crt"

    private_key="/home/replicant/Certs/replicant.p12"

    private_key_passwd=”password"

    eapol_flags=0

}

```

Thank you.

[Moderator edit: added [code] tags to preserve output layout. -Hu]

----------

## Telemin

Okay, so you essentially have two options when it comes to configuring your network,  you either run /etc/init.d/net.<iface> which you add to run at startup with rc-update, OR you setup wpa_supplicant and dhcpcd and run them both as services using the init scripts.  I'm not sure from what you wrote but I have the suspicion you are trying to hybridize.

Your configs otherwise look okay, so I wonder if the issue is the wrong init scripts being selected.  You should only need /etc/init.d/net.if0 in your runlevel and leave wpa_supplicant and dhcpcd out.

You can confirm what is in your default runlevel by running "rc-update show" as root.

Also, although you don't need it, the lack of an init script for dhcpcd is suspicious, you should have one.  Can you confirm that net-misc/dhcpcd is definitely installed, you should get output from "emerge -s dhcpcd" that lists the installed version, e.g.:

```

$ emerge -s dhcpcd

*  net-misc/dhcpcd

      Latest version available: 7.0.0_beta3

      Latest version installed: 7.0.0_beta3

      Size of files: 199 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd/

      Description:   A fully featured, yet light weight RFC2131 compliant DHCP client

      License:       BSD-2

```

-Telemin-

----------

## charles17

 *replicant1 wrote:*   

> I'd like to get dhcp working automatically, but I am not sure what to do. 

 Did you read this wiki article?

----------

## replicant1

Telemin - 

My goal is to get wpa_supplicant and dhcpcd to work automatically. The interface script (net.if0) already exists in the default run level and that doesn't work  :Sad: . I have to run dhcpcd manually to get an ip address.

I removed wpa_supplicant from the default run level and now I don't get any authentication on the radius server  :Sad: . 

This is the output from "rc-update show"

```

                acpid | boot                                   

            alsasound | boot                                   

               binfmt | boot                                   

             bootmisc | boot                                   

           consolekit |      default                           

             cpupower | boot                                   

               cronie |      default                           

                cupsd |      default                           

                 dbus |      default                           

    detect-video-card | boot                                   

                devfs |                                 sysinit

                dmesg |                                 sysinit

                 fsck | boot                                   

               hajime |                                 sysinit

             hostname | boot                                   

              hwclock | boot                                   

              keymaps | boot                                   

            killprocs |                        shutdown        

    kmod-static-nodes |                                 sysinit

                local |              nonetwork                 

           localmount | boot                                   

             loopback | boot                                   

              metalog |      default                           

              modules | boot                                   

             mount-ro |                        shutdown        

                 mtab | boot                                   

              net.if0 |      default                           

           ntp-client |      default                           

                 ntpd |      default                           

     opentmpfiles-dev |                                 sysinit

   opentmpfiles-setup | boot                                   

               procfs | boot                                   

                 root | boot                                   

            savecache |                        shutdown        

               smartd | boot                                   

                 sshd |      default                           

                 swap | boot                                   

               sysctl | boot                                   

                sysfs |                                 sysinit

         termencoding | boot                                   

           truststore | boot                                   

                 udev |                                 sysinit

         udev-trigger |                                 sysinit

           update-crl |      default                           

              urandom | boot                                   

                  xdm |      default                           

```

This is the output from emerge -s dhcpcd:

```

$ sudo emerge -s dhcpcd

Password: 

  

[ Results for search key : dhcpcd ]

Searching...

*  net-libs/dhcpcd-dbus [ Masked ]

      Latest version available: 0.6.1

      Latest version installed: [ Not Installed ]

      Size of files: 22 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd-dbus/

      Description:   DBus bindings for dhcpcd

      License:       BSD-2

*  net-misc/dhcp

      Latest version available: 4.3.4

      Latest version installed: 4.3.4

      Size of files: 9,085 KiB

      Homepage:      http://www.isc.org/products/DHCP

      Description:   ISC Dynamic Host Configuration Protocol (DHCP) client/server

      License:       ISC BSD SSLeay GPL-2

*  net-misc/dhcpcd

      Latest version available: 6.11.3

      Latest version installed: 6.11.3

      Size of files: 191 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd/

      Description:   A fully featured, yet light weight RFC2131 compliant DHCP client

      License:       BSD-2

*  net-misc/dhcpcd-ui

      Latest version available: 0.7.5-r1

      Latest version installed: [ Not Installed ]

      Size of files: 205 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd-ui/

      Description:   Desktop notification and configuration for dhcpcd

      License:       BSD-2

[ Applications found : 4 ]

```

charles17 - 

This is what I get when I try to add dhcpcd to the default run level: 

```

$ sudo rc-update add dhcpcd

Password: 

 * rc-update: service `dhcpcd' does not exist
```

[Moderator edit: added [code] tags to preserve output layout. -Hu]

----------

## Telemin

Okay, I misunderstood, sorry.  So you would prefer not to use netifrc (i.e the net.*) scripts, just let dhcpcd handle things, correct?

I don't know why there is no dhcpcd init file, but the dhcpcd ebuild installs it unconditionally, so remerging dhcpcd should fix that for you.  At that point you can just ignore the net.* scripts completely and just start wpa_supplicant and dhcpcd.  In theory dhcpcd has a wpa_supplicant run-hook, but I am not sure if it will work for radius on ethernet so better to just start it.

As for why the net.if0 script doesn't work... I am not totally sure, everything you have in there looks correct to me.  You do have both the dhcp and dhcpcd clients installed, but that shouldn't matter because openrc will just use its preference.  I presume if0 is the name of the interface according to ifconfig? (It is not my intention to insult your intelligence here, but people do misunderstand the whole interface naming thing sometimes, and udev persistent naming rules have changed everything recently too :rolleyes: )

-Telemin-

----------

## replicant1

No need to be sorry. You are helping me a lot. Because I got it to work by manually starting dhcpcd, that seems to be the easiest route? If I can get dhcpcd started, that would be great. If I can get it to work with the net.interface scripts, that would work too, but I have no idea how that is supposed to work. According to the documentation I have found, I just to have to edit the config files like I have, and everything should just work. 

I have tried reemerging dhcpcd, but it doesn't add the init script  :Sad: .

if0 is my wired ethernet interface as shown when I run "ip addr". I have if0, wlan0, lo, and sit0. I only have net.if0 and net.lo in /etc/init.d. Don't worry about insulting my intelligence. There isn't much there to insult  :Smile: .  I am a complete gentoo newbie. 

If I got a copy of the dhcpcd init script and copied it to /etc/init.d, would that work?

----------

## charles17

 *replicant1 wrote:*   

> I have tried reemerging dhcpcd, but it doesn't add the init script .

 Please verify which version are you having installed

```
$ emerge -s %dhcpcd$

  

[ Results for search key : %dhcpcd$ ]

Searching...

*  net-misc/dhcpcd

      Latest version available: 6.11.3

      Latest version installed: 6.11.3

      Size of files: 191 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd/

      Description:   A fully featured, yet light weight RFC2131 compliant DHCP client

      License:       BSD-2

[ Applications found : 1 ]
```

And search for the missing files

```
$ qlist dhcpcd | grep /etc

/etc/init.d/dhcpcd

/etc/dhcpcd.conf
```

Also your output of emerge --info would be helpful for helping you.

----------

## replicant1

Here is the ouput for the dhcpcd version:

```

$ sudo emerge -s %dhcpcd$ 

  

[ Results for search key : %dhcpcd$ ]

Searching...

*  net-misc/dhcpcd

      Latest version available: 6.11.3

      Latest version installed: 6.11.3

      Size of files: 191 KiB

      Homepage:      http://roy.marples.name/projects/dhcpcd/

      Description:   A fully featured, yet light weight RFC2131 compliant DHCP client

      License:       BSD-2

[ Applications found : 1 ]

```

Here is the output for the dhcpcd files

```

$ sudo qlist dhcpcd | grep /etc 

/etc/dhcpcd.conf

```

Here is the output for emerge --info. 

```

Portage 2.3.3 (python 3.4.5-final-0, !../../var/portage/repos/contoso-private/profiles/linux/default/amd64/laptop-workstation, gcc-4.9.4, glibc-2.23-r3, 4.9.22-vanilla-workstation-2 x86_64)

=================================================================

System uname: Linux-4.9.22-vanilla-workstation-2-x86_64-Intel-R-_Core-TM-_i7-5600U_CPU_@_2.60GHz-with-gentoo-2.3

KiB Mem:     7856420 total,   6474776 free

KiB Swap:          0 total,         0 free

Timestamp of repository gentoo: Thu, 27 Apr 2017 00:00:01 +0000

Timestamp of repository constoso-private: Thu, 27 Apr 2017 00:06:57 +0000

Timestamp of repository constoso-public: Wed, 26 Apr 2017 23:31:16 +0000

Timestamp of repository constoso-security: Tue, 25 Apr 2017 01:12:04 +0000

sh bash 4.3_p48-r1

ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1

app-shells/bash:          4.3_p48-r1::gentoo

dev-java/java-config:     2.2.0-r3::gentoo

dev-lang/perl:            5.22.3_rc4::gentoo

dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo

dev-util/cmake:           3.7.2::gentoo

dev-util/pkgconfig:       0.28-r2::gentoo

sys-apps/baselayout:      2.3::gentoo

sys-apps/openrc:          0.23.2::gentoo

sys-apps/sandbox:         2.10-r3::gentoo

sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo

sys-devel/automake:       1.15::gentoo

sys-devel/binutils:       2.26.1::gentoo

sys-devel/gcc:            4.9.4::gentoo

sys-devel/gcc-config:     1.7.3::gentoo

sys-devel/libtool:        2.4.6-r3::gentoo

sys-devel/make:           4.2.1::gentoo

sys-kernel/linux-headers: 4.9::gentoo (virtual/os-headers)

sys-libs/glibc:           2.23-r3::gentoo

Repositories:

gentoo

    location: /var/portage/repos/gentoo

    sync-type: rsync

    sync-uri: rsync://gentoo.constoso.org/gentoo-portage

    priority: -1000

contoso-private

    location: /var/portage/repos/contoso-private

    sync-type: rsync

    sync-uri: rsync://gentoo.contoso.org/contoso-private

    masters: gentoo contoso-public

contoso-public

    location: /var/portage/repos/contoso-public

    sync-type: rsync

    sync-uri: rsync://gentoo.contoso.org/contoso-public

    masters: gentoo

contoso-security

    location: /var/portage/repos/contoso-security

    sync-type: rsync

    sync-uri: rsync://gentoo.contoso.org/contoso-security-base-20160627

    masters: gentoo

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="*"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -g -march=corei7 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-O2 -g -march=corei7 -pipe"

DISTDIR="/var/portage/distfiles"

EMERGE_DEFAULT_OPTS="--jobs=4 --load-average=4"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://gentoo.contoso.org http://distfiles.gentoo.org"

INSTALL_MASK="/usr/lib/systemd/system /usr/lib/systemd/system-sleep /lib/systemd/system"

LANG="en_US.utf8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j8"

PKGDIR="/var/portage/packages"

PORTAGE_COMPRESS="xz"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"

PORTAGE_TMPDIR="/var/tmp"

USE="X aac acl acpi alsa amd64 apng avx bash-completion bluetooth bzip2 cairo caps cdda cdio cli consolekit cracklib crypt cups curl cxx dbus device-mapper dri dvd egl exif ffmpeg fftw flac fuse gif git gmp gnome-keyring gpm gtk iconv ipv6 ithreads jbit jpeg jpeg2k keybinder laptop-workstation lcms libffi libnotify lm_sensors lzma lzo mad mmap mmx mmxext mng modules mp3 mtp multilib ncurses networking networkmanager nptl ogg openal opengl openmp openssl openvg opus pam pcre pdf png pnm policykit pulseaudio python readline seccomp session sndfile spell sqlite sse sse2 sse3 sse4_1 ssl ssse3 startup-notification svg theora threads tiff truetype udev unicode usb usbredir vaapi vdpau vim vim-syntax vorbis vpx workstation x264 xattr xcb xinerama xorg xv zlib zsh-completion" ABI_X86="64 32" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy nvidia qxl v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

USE_PYTHON="2.7"

Unset:  CC, CPPFLAGS, CTARGET, CXX, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

The repositories with the name contoso (I made that name up) are local to where I am. 

If I remove wpa_supplicant from the /etc/conf.d/net config and just leave dhcpcd defined for modules_if0, dhcp works automatically on startup on a port that doesn't require NAC. I can actually see it acquire an address on boot. When I add wpa_supplicant, dhcp doesn't start.

----------

## charles17

 *replicant1 wrote:*   

> Here is the output for the dhcpcd files
> 
> ```
> 
> $ sudo qlist dhcpcd | grep /etc 
> ...

 

The question is why doesn't it have the init file. Pls check if it comes back after re-emerge

```
emerge -1avt net-misc/dhcpcd::gentoo
```

----------

## replicant1

The init file doesn't show up after a re-remerge. 

```

$ sudo emerge -lavt net-misc/dhcpcd::gentoo

Password: 

These are the packages that would be merged, in reverse order:

Calculating dependencies... done!

[ebuild   R    ] net-misc/dhcpcd-6.11.3::gentoo  USE="embedded ipv6 udev" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] Yes

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) net-misc/dhcpcd-6.11.3::gentoo

>>> Installing (1 of 1) net-misc/dhcpcd-6.11.3::gentoo

>>> Recording net-misc/dhcpcd::gentoo in "world" favorites file...

>>> Jobs: 1 of 1 complete                           Load avg: 0.16, 0.04, 0.14

>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

```

```

$ sudo qlist dhcpcd | grep /etc

/etc/dhcpcd.conf

```

----------

## charles17

Something in your emerge went wrong. As a workaround you could copy that file directly from the package:

```
cp /usr/portage/net-misc/dhcpcd/files/dhcpcd.initd /etc/init.d/dhcpcd
```

But that's not a solution.  You should find out why your emerge did wrong and get that fixed.

----------

