Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 755200 - net-misc/dhcpcd works on statically configured interfaces
Summary: net-misc/dhcpcd works on statically configured interfaces
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-18 06:40 UTC by Gerrit Kühn
Modified: 2020-11-25 08:53 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerrit Kühn 2020-11-18 06:40:28 UTC
I found a strange issue (at least to me) when doing a new Gentoo installation recently:

I have the following /etc/conf.d/net file:

dev-01 ~ # cat /etc/conf.d/net
config_eth0="noop"
config_eno2="192.168.1.1/24"
mtu_eno2="9000"


The initial IP setup for eth0 (192.168.224.71/24) comes from the kernel during PXE boot, dhcpcd takes over after booting. However, my problem is with the additional static eno2 interface. dhcpcd works on this, too, and broadcasts for a lease. It receives an answer and even uses this for eno2, but apparently it gets overwritten by the static settings from above later down the road:

Nov 17 21:27:24 dev-01 dhcpcd[4669]: eno2: carrier acquired
Nov 17 21:27:24 dev-01 dhcpcd[4669]: eno2: IAID 6b:b3:fb:6b
Nov 17 21:27:24 dev-01 dhcpcd[4669]: eno2: adding address fe80::a014:b366:7a23:a
101
Nov 17 21:27:24 dev-01 dhcpcd[4669]: eno2: soliciting an IPv6 router
Nov 17 21:27:25 dev-01 dhcpcd[4669]: eno2: rebinding lease of 192.168.225.154
Nov 17 21:27:25 dev-01 dhcpcd[4669]: eno2: probing address 192.168.225.154/19
Nov 17 21:27:29 dev-01 dhcpcd[4669]: eno2: leased 192.168.225.154 for 3600 seconds
Nov 17 21:27:29 dev-01 dhcpcd[4669]: eno2: adding route to 192.168.224.0/19
Nov 17 21:27:29 dev-01 dhcpcd[4669]: eno2: adding default route via 192.168.224.254
Nov 17 21:27:33 dev-01 dhcpcd[4669]: eth0: no IPv6 Routers available
Nov 17 21:27:37 dev-01 dhcpcd[4669]: eno2: no IPv6 Routers available


However, the created routes remain:

dev-01 ~ # netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.224.254 0.0.0.0         UG        0 0          0 eth0
0.0.0.0         192.168.224.254 0.0.0.0         UG        0 0          0 eno2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eno2
192.168.224.0   0.0.0.0         255.255.224.0   U         0 0          0 eth0
192.168.224.0   0.0.0.0         255.255.224.0   U         0 0          0 eno2


This is the (correct) interface setup I get (and want):

eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        ether ac:1f:6b:b3:fb:6b  txqueuelen 1000  (Ethernet)
        RX packets 1329  bytes 154918 (151.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 93  bytes 9239 (9.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfb100000-fb11ffff  

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.224.71  netmask 255.255.224.0  broadcast 192.168.224.255
        inet6 fe80::ae1f:6bff:feb3:fb6a  prefixlen 64  scopeid 0x20<link>
        ether ac:1f:6b:b3:fb:6a  txqueuelen 1000  (Ethernet)
        RX packets 190531  bytes 158607430 (151.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 140522  bytes 82229653 (78.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfb120000-fb13ffff  


So requesting the additional lease over eno2 messes up the routing table, and sooner or later breaks the nfsroot the machine is working on.
The only way I found to keep dhcpcd from doing this is to set
denyinterfaces eno2
in /etc/dhcpcd.conf. Then everything works as expected.


In my opinion, this should not happen. When the interface is configured statically in /etc/conf.d/net, dhcpcd should not touch it at all. Or, if it does, and the explicit denyinterfaces setting is actually a requirement, this should be mentioned in the install guide.
I've been using this kind of setup for many years, I'm pretty sure older versions of dhcpcd (or openrc/netif?) behaved differently. What I have installed is the standard version, just following the installation guide:

net-misc/dhcpcd-8.1.9::gentoo  USE="embedded ipv6 udev"
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2020-11-18 08:50:59 UTC
Please post the output of

  emerge --info netifrc

(preferrably as comment) to this bug.
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2020-11-18 08:57:05 UTC
Do you have added the dhcpcd init script to any of your runlevels? What does

  rc-service dhcpcd status

return?
Comment 3 Gerrit Kühn 2020-11-23 21:34:12 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #2)

> Do you have added the dhcpcd init script to any of your runlevels? What does
> 
>   rc-service dhcpcd status
> 
> return?

Yes, it is started in default as I need it for eth0:

dev-01 ~ # rc-service dhcpcd status
 * status: started
Comment 4 Gerrit Kühn 2020-11-23 21:37:43 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #1)
> Please post the output of
> 
>   emerge --info netifrc
> 
> (preferrably as comment) to this bug.

Portage 3.0.4 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-9.3.0, glibc-2.31-r6, 5.4.66-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.4.66-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5-1650_v4_@_3.60GHz-with-gentoo-2.7
Portage 3.0.4 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-9.3.0, glibc-2.31-r6, 5.4.6
6-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.4.66-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5-1650_v4_@_3.60GHz-with-gentoo
-2.7
KiB Mem:    32771664 total,  32338104 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Tue, 29 Sep 2020 13:30:01 +0000
Head commit of repository gentoo: fb879da254a52f20814969cb630e0dfc9ae03b04
sh bash 5.0_p18
ld GNU ld (Gentoo 2.34 p6) 2.34.0
distcc 3.3.3 x86_64-pc-linux-gnu [enabled]
ccache version 3.7.11 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r2::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo
dev-util/ccache:          3.7.11::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.18::gentoo
sys-devel/autoconf:       2.69-r5::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=nehalem -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=nehalem -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" --usepkg"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=nehalem -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg ccache config-protect-if-modified distcc distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=nehalem -O2 -pipe"
GENTOO_MIRRORS="ftp://mirror.netcologne.de/gentoo/ https://mirror.netcologne.de/gentoo/ http://mirror.netcologne.de/gentoo/ rsync://mirror.netcologne.de/gentoo/ https://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ https://ftp.halifax.rwth-aachen.de/gentoo/ http://ftp.halifax.rwth-aachen.de/gentoo/ ftp://ftp.halifax.rwth-aachen.de/gentoo/ rsync://ftp.halifax.rwth-aachen.de/gentoo/ https://ftp.fau.de/gentoo http://ftp.fau.de/gentoo ftp://ftp.fau.de/gentoo rsync://ftp.fau.de/gentoo https://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ ftp://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ rsync://ftp-stud.hs-esslingen.de/gentoo/"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="de en en_US en_GB"
MAKEOPTS=" -j313 -l12"
PKGDIR="/var/cache/binpkgs"
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="acl amd64 berkdb bindist bzip2 cli crypt dri fortran gdbm iconv ipv6 libglvnd libtirpc mmx multilib ncurses nls nptl openmp pam pcre readline seccomp split-usr sse sse2 ssl tcpd unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2018" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx sse sse2 mmx mmxext" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy 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"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

net-misc/netifrc-0.7.1::gentoo was built with the following:
USE="" ABI_X86="(64)"
CFLAGS="-O2 -pipe"
Comment 5 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2020-11-23 22:14:15 UTC
(In reply to Gerrit Kühn from comment #0)
> 
> In my opinion, this should not happen. When the interface is configured
> statically in /etc/conf.d/net, dhcpcd should not touch it at all. Or, if it
> does, and the explicit denyinterfaces setting is actually a requirement,
> this should be mentioned in the install guide.
> I've been using this kind of setup for many years, I'm pretty sure older
> versions of dhcpcd (or openrc/netif?) behaved differently. What I have
> installed is the standard version, just following the installation guide:
> 
> net-misc/dhcpcd-8.1.9::gentoo  USE="embedded ipv6 udev"


You're using two different services to configure your network and expect them to not interfere with each other (dhcpcd as daemon and netifrc)?
Why don't you simply use netifrc for both interfaces?

  config_eth0="dhcpcd"

And if you need special dhcpcd parameters simply use

  dhcpcd_eth0="-t 20 -q -A"

(just to show an example of what I am using in my netifrc setting)
Comment 6 Gerrit Kühn 2020-11-25 08:17:56 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #5)

> You're using two different services to configure your network and expect
> them to not interfere with each other (dhcpcd as daemon and netifrc)?

Sorry, I don't quite understand... oh, maybe I do: You're saying I should have netifrc run dhcpcd, so it will take care of limiting the devices it sees? Thinking about it, this makes perfect sense. Somehow I had anticipated that dhcpcd would honour the settings in conf.d/net when started by openrc, but of course it doesn't.

Just tested this, and it looks like it is working as expected. Sorry for the noise, this was all my misconception about who is responsible for parsing conf.d/net in this case (netifrc does that, not openrc/init-scripts).
Comment 7 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2020-11-25 08:53:56 UTC
(In reply to Gerrit Kühn from comment #6)
> 
> Just tested this, and it looks like it is working as expected. Sorry for the
> noise, this was all my misconception about who is responsible for parsing
> conf.d/net in this case (netifrc does that, not openrc/init-scripts).

Don't worry. We all have these kind of moments sometimes. I'm glad it works for you now :)