View previous topic :: View next topic |
Author |
Message |
marcelser Tux's lil' helper
Joined: 30 Sep 2004 Posts: 102
|
Posted: Sat Dec 28, 2024 12:08 pm Post subject: dhcpcd first acquiring correct IP, then renewing to sth else |
|
|
since the last world update and emerge my dhcpcd is driving me mad.
I have set the IP of my machine in the router (IP to mac binding) to 192.168.1.50, this used to work. Now when the machine boots it first acquires 192.168.1.50 (when all leases have been cleaned) but then somewhere in the middle of the boot process it requests a new dhdpcd and then it switches to 192.168.199 (or some dynamic dhcp address) I guess because 192.168.1.50 is already in use (by itself) and so the router cannot hand it again out so it returns a new one. As I'm running a bunch of servers on the machine (apache, mmonit, teamspieak, some api, etc.) It's crucial that the IP does not change once it got acquired from dhcpcd. I also don't get where and how it could re-request a dhcp it has never happened before.
I already tried deleting the lease in /var/lib/dhcpcd/ for the network card and also cleaning the lease in the router for this DUID & MAC without success. I then again first requests 192.168.1.50 which is correct and for a short time I can even connect to it with ssh but then after few seconds it kicks in a second dhcp request and corrupts the 192.168.1.50 with something dynamic handed out by the router.
Any ideas how I can stop this (apart from setting everything manually which would be a pain in the ass)
I'm totally clueless what is happening |
|
Back to top |
|
|
Banana Moderator
Joined: 21 May 2004 Posts: 1811 Location: Germany
|
|
Back to top |
|
|
gentoo_ram Guru
Joined: 25 Oct 2007 Posts: 504 Location: San Diego, California USA
|
Posted: Sat Dec 28, 2024 4:53 pm Post subject: |
|
|
Maybe you have two different DHCP client programs running? Or maybe you are starting 'dhcpcd' as a daemon which configures all interfaces by default and then later your system is starting a network device startup script which runs a DHCP client again on the specific interface.
Are you using systemd or open-rc? |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6182 Location: Dallas area
|
Posted: Sat Dec 28, 2024 5:51 pm Post subject: |
|
|
You're setting it on the router, are you telling dhcpd to use that same ip address?
Are both the router and dhcpd on your computer trying to be dhcp server? Pick one of the to be the server.
I don't use dhcpd on my machine, I hard set it to a specific address.
On the router I have a range of ips that I tell the router to leave out of dhcp serving.
In other words I have 2-50 for static ips and let the router handle 51-254. _________________ UM780, 6.12 zen kernel, gcc 13, openrc, wayland |
|
Back to top |
|
|
marcelser Tux's lil' helper
Joined: 30 Sep 2004 Posts: 102
|
Posted: Sun Dec 29, 2024 2:27 pm Post subject: |
|
|
I checked and the MAC address looks fine.
gentoo_ram wrote: | Maybe you have two different DHCP client programs running? Or maybe you are starting 'dhcpcd' as a daemon which configures all interfaces by default and then later your system is starting a network device startup script which runs a DHCP client again on the specific interface.
Are you using systemd or open-rc? |
Well in fact I have only one DHCPv4 running (dnsmasq on a no longer used openwrt router) and one DHCPv6 (on my ISPs fiber box, I disabled DHCPv4 there). I can also see that both IPs assigned which is first the static IP 192.168.1.50 and later changes to 192.168.1.xxx (fom 100-255) are both assigned by dnsmasq, I can see it in /temp/dhcp.leases file from dnsmasq/openwrt where I can first see an entry with the static ip 192.168.1.50 which then gets updated with the dynamic IP served by DHCP.
Anon-E-moose wrote: | You're setting it on the router, are you telling dhcpd to use that same ip address?
Are both the router and dhcpd on your computer trying to be dhcp server? Pick one of the to be the server.
I don't use dhcpd on my machine, I hard set it to a specific address.
On the router I have a range of ips that I tell the router to leave out of dhcp serving.
In other words I have 2-50 for static ips and let the router handle 51-254. |
Well in fact I have nearly the same setup. I have a range excluded from 1-100 for fixed IPs and 100-255 served by the DHCP server which in my case is dnsmasq. But I also like to manage all my fixed IPs in dnsmasq gui because it has inherent advantages like having on overview which fixed IPs are taken and which ones are free and I don't have to fiddle around on any device (except at the moment gentoo) and it also automatically assigns DNS Servers, Gateway, Routes, NTP Server etc if you have a clever DHCP server like dnsmasq which let's you set the specific DHCP flags (I know usual cheap consumer routers don't have it and also most ISP routers are lacking this). So for the moment I have configured all of this stuff manually on my gentoo box for IPv4 (whereas for IPv6 I get a proper IP & Default Router" set by the DHCPv6 when using dhcpcd with a proper conf file and ipv6only for the time beeing).
Maybe just to complete the picture here's met /etc/conf.d/net config (before setting everything to manual IP).
Code: | config_enp0s25="dhcp
192.168.1.37/24 label enp0s25:0"
# MAC-VLAN support
# The following configuration can be used to create a new interface 'macvlan0'
# linked to 'eth0'
macvlan_macvlan0="enp0s25"
# MAC-VLAN mode (private, vepa, bridge, passtru)
mode_macvlan0="bridge"
# MAC-VLAN type (macvlan, macvtap)
type_macvlan0="macvlan"
# IP address, MAC address, ... are configured as a normal interface
config_macvlan0="192.168.1.20/30"
mac_macvlan0="00:50:06:20:20:20"
broadcast_macvlan0="0.0.0.0"
|
Well at the moment I have modified it by replacing "dhcp" a the top by "192.168.1.50" and adding routes, dns & ntp server entries. Do you see any reason why it could try assigning DHCP to enp0s25 twice with this config? As I would like to go back to DHCPv4 if somehow possible. And as I said it used to work with the a default dhdpcd.conf which is probably anyhow not used when you setup dhcp this way but I don't know. Now that I have configured dhdpcd.conf for ipv6only I had to add dhdpcd to the default runlevel as a service. But when having "dhcp" in the network config it starts it somehow automatically not through the startup script.
As you can see I assign a 2nd IP to the interface which is static as an alias (I need this to run unbound on that IP) and I also need a macvlan interface which is used by some docker service where the usual docker way of networking didn't work as I needed an externally exposed separate IP on a 2nd interface.
I agree not the simplest setup.
For completeness here's also the dhcpcd.conf with the added ipv6 section at the buttom:
Code: | # A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
#hostname
# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid
# Persist interface configuration when dhcpcd exits.
persistent
# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Request a hostname from the network
option host_name
# Most distributions have NTP support.
#option ntp_servers
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
#slaac private
# disable auto-overwrite of resolv.conf
nohook resolv.conf
##### ipv6 from here on
ipv6only
interface enp0s25
iaid 100
ia_na
|
|
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6182 Location: Dallas area
|
Posted: Sun Dec 29, 2024 3:46 pm Post subject: |
|
|
I try and simplify if possible, I don't tell dhcp about it. I do have a few entries in /etc/hosts and I do run unbound just as a local server.
Never tried dnsmasq, so no thoughts on that part.
And I don't do vlans, so relatively simple.
Code: | $ cat /etc/conf.d/net
...
config_eth0="192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255"
routes_eth0="default via 192.168.1.1" |
_________________ UM780, 6.12 zen kernel, gcc 13, openrc, wayland |
|
Back to top |
|
|
marcelser Tux's lil' helper
Joined: 30 Sep 2004 Posts: 102
|
Posted: Sun Dec 29, 2024 5:10 pm Post subject: |
|
|
Anon-E-moose wrote: | I try and simplify if possible, I don't tell dhcp about it. I do have a few entries in /etc/hosts and I do run unbound just as a local server.
Never tried dnsmasq, so no thoughts on that part.
And I don't do vlans, so relatively simple.
Code: | $ cat /etc/conf.d/net
...
config_eth0="192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255"
routes_eth0="default via 192.168.1.1" |
|
I appreciate that you're trying to help but I do have it running without DHCPv4 at the moment. But the whole point of this thread is how do I re-enable it for above mentioned reasons, so not really helpful in that regards. But yeah I'm also running unbound just as local resolver which doesn't work when you use dhcp, you need a fixed address for the config files hence that alias to 192.168.1.37. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|