Il problema
Impossibile avviare in modo affidabile la rete su un server quando si utilizza DHCP:
# sudo /etc/init.d/network restart Restarting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details. [FAILED]
# journalctl -xe Nov 29 18:57:42 hostaname.domain.com dhclient[37653]: exiting. Nov 29 18:57:42 hostaname.domain.com network[37498]: [FAILED] Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com network[37498]: RTNETLINK answers: File Nov 29 18:57:42 hostaname.domain.com systemd[1]: network.service: control pr Nov 29 18:57:42 hostaname.domain.com systemd[1]: Failed to start LSB: Bring -- Subject: Unit network.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit network.service has failed. -- -- The result is failed. Nov 29 18:57:42 hostaname.domain.com systemd[1]: Unit network.service entere Nov 29 18:57:42 hostaname.domain.com systemd[1]: network.service failed. Nov 29 18:57:42 hostaname.domain.com polkitd[36998]: Unregistered Authentica
# sudo systemctl status -l network.service ● network.service - LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2016-12-12 12:48:04 EST; 28s ago Docs: man:systemd-sysv-generator(8) Process: 17797 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS) Process: 18067 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE) Dec 12 12:47:58 hostname.domain.com network[18067]: [FAILED] Dec 12 12:47:58 hostname.domain.com network[18067]: Bringing up interface eth1: Dec 12 12:48:04 hostname.domain.com network[18067]: Determining IP information for eth1... failed; no link present. Check cable? Dec 12 12:48:04 hostname.domain.com network[18067]: [FAILED] Dec 12 12:48:04 hostname.domain.com network[18067]: /etc/rc.d/init.d/network: line 88: ifcfg-eth0:DEVICE=eth0: command not found Dec 12 12:48:04 hostname.domain.com network[18067]: /etc/rc.d/init.d/network: line 89: ifcfg-eth0:TYPE=Ethernet: command not found Dec 12 12:48:04 hostname.domain.com systemd[1]: network.service: control process exited, code=exited status=1 Dec 12 12:48:04 hostname.domain.com systemd[1]: Failed to start LSB: Bring up/down networking. Dec 12 12:48:04 hostname.domain.com systemd[1]: Unit network.service entered failed state. Dec 12 12:48:04 hostname.domain.com systemd[1]: network.service failed.
file di configurazione di rete:
# less /etc/sysconfig/network-scripts/ifcfg-eth0 # Generated by parse-kickstart IPV6INIT=yes BOOTPROTO=dhcp DEVICE=eth0 ONBOOT=yes UUID=ccb107d4-4be6-453b-80f2-f803acc5f897 TYPE=Ethernet DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME="System eth0" PEERDNS=yes PEERROUTES=yes DHCP_HOSTNAME=IPV6_PEERDNS=yes IPV6_PEERROUTES=yes
La soluzione
Un sistema CentOS/RHEL configurato per la rete DHCP non riesce ad acquisire un indirizzo IP durante il riavvio del servizio di rete. Aggiunta del parametro PERSISTENT_DHCLIENT al file di configurazione dell'interfaccia di rete assicura che il client DHCP Oracle Linux (dhclient) richieda costantemente un lease di indirizzi IP dal server DHCP.
1. Aggiungi PERSISTENT_DHCLIENT direttiva in /etc/sysconfig/network file come segue:
# vi /etc/sysconfig/network NETWORKING=yes PERSISTENT_DHCLIENT=yes
2.Riavvia i servizi di rete:
# /sbin/service network restart ## For CentOS/RHEL 5/6 # /usr/bin/systemctl restart network ## For CentOS/RHEL 7/8