Setting desktop hostname/domainname via DHCP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I had the following /etc/dhcp/dhclient.d/hostname.sh script (root.root and 755):

#!/bin/bash

hostname_config() {
	domain_portion="$(echo "${new_host_name}" | cut -s -d. -f2-)"
	[ -z "${domain_portion}" ] || return
	[ -n "${new_domain_name}" ] || return
	logger -p info -t hostname.sh "Setting domainname ${new_domain_name}"
	domainname "${new_domain_name}"
}

hostname_restore() {
	# nothing to do
	:
}

And it had been working until I upgraded from F33 to F34.

I also tried adding the following /etc/NetworkManager/dispatcher.d/hostname.sh script (root.root and 755):

#!/bin/bash

# Make sure to run:
#	systemctl enable NetworkManager-dispatcher.service
#

log()
{
    if [ $# -gt 0 ]; then
	    logger -i -p daemon.info -t "$PROG" "$@"
    else
        while read line; do
            logger -i -p daemon.info -t "$PROG" "$line"
        done
    fi
}

PROG="$(basename "$0")"

INTF="$1"
ACTION="$2"

# log "args: '$INTF' '$ACTION'"
# env | sort | log

case "$ACTION" in
hostname)
    log "hostname: $(hostname)"
    ;;

up)
    log "up: '${DHCP4_HOST_NAME}.${DHCP4_DOMAIN_NAME}'"
    hostname "${DHCP4_HOST_NAME}"
    domainname "${DHCP4_DOMAIN_NAME}"
    ;;
esac

exit 0

After enabling the dispatcher service (still not sure how it got disabled), I run "ifdown ifcfg-ens3" and then "ifup" it again, and see:

Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.5640] audit: op="connections-load" args="/etc/sysconfig/network-scripts/ifcfg-ens3" pid=4589 uid=0 result="success"
Nov  6 14:37:43 mail ifup[4593]: You are using 'ifup' script provided by 'network-scripts', which are now deprecated.
Nov  6 14:37:43 mail ifup[4594]: 'network-scripts' will be removed from distribution in near future.
Nov  6 14:37:43 mail ifup[4595]: It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well.
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6537] agent-manager: agent[deba009519da797d,:1.174/nmcli-connect/0]: agent registered
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6552] device (ens3): Activation: starting connection 'System ens3' (db7b64ba-a781-4456-8a0f-9d41a8e8904b)
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6553] audit: op="connection-activate" uuid="db7b64ba-a781-4456-8a0f-9d41a8e8904b" name="System ens3" pid=4601 uid=0 result="success"
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6555] device (ens3): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6569] manager: NetworkManager state is now CONNECTING
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6574] device (ens3): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6630] device (ens3): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6641] dhcp4 (ens3): activation: beginning transaction (timeout in 45 seconds)
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6903] dhcp4 (ens3): state changed unknown -> bound, address=192.168.4.3
Nov  6 14:37:43 mail avahi-daemon[831]: Joining mDNS multicast group on interface ens3.IPv4 with address 192.168.4.3.
Nov  6 14:37:43 mail avahi-daemon[831]: New relevant interface ens3.IPv4 for mDNS.
Nov  6 14:37:43 mail avahi-daemon[831]: Registering new address record for 192.168.4.3 on ens3.IPv4.
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6953] device (ens3): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6992] device (ens3): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.6998] device (ens3): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7014] manager: NetworkManager state is now CONNECTED_LOCAL
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7031] manager: NetworkManager state is now CONNECTED_SITE
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7041] policy: set 'System ens3' (ens3) as default for IPv4 routing and DNS
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7046] policy: set-hostname: current hostname was changed outside NetworkManager: 'localhost.localdomain'
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7048] policy: set-hostname: set hostname to 'mail' (from DHCPv4)
Nov  6 14:37:43 mail systemd-resolved[805]: ens3: Bus client set search domain list to: redfish-solutions.com, redfish-consulting.com
Nov  6 14:37:43 mail systemd-resolved[805]: ens3: Bus client set default route setting: yes
Nov  6 14:37:43 mail audit: BPF prog-id=93 op=LOAD
Nov  6 14:37:43 mail audit: BPF prog-id=94 op=LOAD
Nov  6 14:37:43 mail systemd[1]: Starting Hostname Service...
Nov  6 14:37:43 mail systemd-resolved[805]: ens3: Bus client set DNS server list to: 192.168.4.1
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7421] device (ens3): Activation: successful, device activated.
Nov  6 14:37:43 mail NetworkManager[1946]: <info>  [1636231063.7510] manager: NetworkManager state is now CONNECTED_GLOBAL
Nov  6 14:37:43 mail systemd[1]: Stopping Sendmail Mail Transport Client...
Nov  6 14:37:43 mail systemd[1]: sm-client.service: Deactivated successfully.
Nov  6 14:37:43 mail systemd[1]: Stopped Sendmail Mail Transport Client.
Nov  6 14:37:43 mail audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=sm-client comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:37:43 mail systemd[1]: Stopping Sendmail Mail Transport Agent...
Nov  6 14:37:43 mail systemd[1]: sendmail.service: Deactivated successfully.
Nov  6 14:37:43 mail audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=sendmail comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:37:43 mail systemd[1]: Stopped Sendmail Mail Transport Agent.
Nov  6 14:37:43 mail systemd[1]: Starting Sendmail Mail Transport Agent...
Nov  6 14:37:43 mail 11-dhclient[4615]: Setting domainname redfish-solutions.com
Nov  6 14:37:43 mail systemd[1]: sendmail.service: Can't open PID file /run/sendmail.pid (yet?) after start: Operation not permitted
Nov  6 14:37:43 mail systemd[1]: Started Hostname Service.
Nov  6 14:37:43 mail audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:37:43 mail systemd-hostnamed[4605]: Hostname set to <localhost.localdomain> (static)
Nov  6 14:37:43 mail hostname.sh[4634]: up: 'mail.redfish-solutions.com'
Nov  6 14:37:43 mail systemd[1]: Started Sendmail Mail Transport Agent.
Nov  6 14:37:43 mail audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=sendmail comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:37:43 mail systemd[1]: Starting Sendmail Mail Transport Client...
Nov  6 14:37:43 mail audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=sm-client comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:37:43 mail systemd[1]: Started Sendmail Mail Transport Client.
Nov  6 14:37:43 mail hostname.sh[4665]: hostname: mail
Nov  6 14:37:44 mail avahi-daemon[831]: Joining mDNS multicast group on interface ens3.IPv6 with address fe80::5054:ff:fecf:9482.
Nov  6 14:37:44 mail NetworkManager[1946]: <info>  [1636231064.8628] policy: set-hostname: current hostname was changed outside NetworkManager: 'fedora'
Nov  6 14:37:44 mail NetworkManager[1946]: <info>  [1636231064.8630] policy: set-hostname: set hostname to 'mail' (from DHCPv4)
Nov  6 14:37:44 mail avahi-daemon[831]: New relevant interface ens3.IPv6 for mDNS.
Nov  6 14:37:44 mail systemd-hostnamed[4605]: Hostname set to <localhost.localdomain> (static)
Nov  6 14:37:44 mail avahi-daemon[831]: Registering new address record for fe80::5054:ff:fecf:9482 on ens3.*.
Nov  6 14:37:44 mail systemd-resolved[805]: Failed to determine the local hostname and LLMNR/mDNS names, ignoring: No such device or address
Nov  6 14:37:44 mail hostname.sh[4677]: hostname: localhost.localdomain
Nov  6 14:37:46 mail ntpd[1730]: IO: Listen normally on 24 ens3 192.168.4.3:123
Nov  6 14:37:46 mail ntpd[1730]: IO: Listen normally on 25 ens3 [fe80::5054:ff:fecf:9482%2]:123
Nov  6 14:37:55 mail systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
Nov  6 14:37:55 mail audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov  6 14:38:14 mail systemd[1]: systemd-hostnamed.service: Deactivated successfully.
Nov  6 14:38:14 mail audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'


So I see my script being run here:

Nov  6 14:37:43 mail hostname.sh[4634]: up: 'mail.redfish-solutions.com'


But then shortly after, this happens:


Nov  6 14:37:44 mail NetworkManager[1946]: <info>  [1636231064.8628] policy: set-hostname: current hostname was changed outside NetworkManager: 'fedora'
Nov  6 14:37:44 mail NetworkManager[1946]: <info>  [1636231064.8630] policy: set-hostname: set hostname to 'mail' (from DHCPv4)
...
Nov  6 14:37:44 mail systemd-hostnamed[4605]: Hostname set to <localhost.localdomain> (static)
...
Nov  6 14:37:44 mail systemd-resolved[805]: Failed to determine the local hostname and LLMNR/mDNS names, ignoring: No such device or address


So what's going on?  And how do I make it just accept the DHCP4 provisioned hostname and domain?

This all worked (using just the dhclient.d/ script)... now with F34 installed nothing does.

Thanks,

-Philip
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux