Fedora 21 - 从未发生过网络在线

Fedora 21 - 从未发生过网络在线

我有一些定制服务,这依赖于network-online.target

NetworkManager已删除。 chkconfing network on取代它。

服务有

journalctl -b没有看到network-online发生(例如在 Fedora 20 上)

Jun 07 09:52:04 sssd[pam][822]: Starting up
Jun 07 09:52:04 sssd[nss][821]: Starting up
Jun 07 09:52:04 systemd-logind[846]: New seat seat0.
Jun 07 09:52:04 systemd-logind[846]: Watching system buttons on /dev/input/event0 (Power Button)
Jun 07 09:52:04 network[762]: Bringing up loopback interface:  [  OK  ]
Jun 07 09:52:04 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:04 kernel: bnx2 0000:01:00.0 eno1: using MSIX
Jun 07 09:52:04 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:04 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:04 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:08 kernel: bnx2 0000:01:00.0 eno1: NIC Copper Link is Up, 1000 Mbps full duplex
Jun 07 09:52:08 kernel:
Jun 07 09:52:08 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:08 systemd-networkd[773]: eno1            : gained carrier
Jun 07 09:52:08 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:08 systemd-networkd-wait-online[803]: ignore irrelevant link: lo
Jun 07 09:52:08 network[762]: Bringing up interface eno1:  [  OK  ]
Jun 07 09:52:08 kernel: sfc 0000:03:00.0 sfn0p1: link up at 10000Mbps full-duplex (MTU 1500)
Jun 07 09:52:08 network[762]: Bringing up interface sfn0p1:  [  OK  ]
Jun 07 09:52:08 kernel: sfc 0000:03:00.1 sfn0p2: link up at 10000Mbps full-duplex (MTU 1500)
Jun 07 09:52:09 network[762]: Bringing up interface sfn0p2:  [  OK  ]
Jun 07 09:52:09 kernel: 8021q: 802.1Q VLAN Support v1.8
Jun 07 09:52:09 systemd-networkd[773]: sfn0p1.1273     : gained carrier
Jun 07 09:52:09 systemd-networkd[773]: sfn0p1          : gained carrier
Jun 07 09:52:09 systemd-networkd[773]: sfn0p2          : gained carrier
Jun 07 09:52:13 network[762]: Bringing up interface sfn0p1.1273:  [  OK  ]
Jun 07 09:52:13 systemd-networkd[773]: sfn0p1.1373     : gained carrier
Jun 07 09:52:17 network[762]: Bringing up interface sfn0p1.1373:  [  OK  ]
Jun 07 09:52:17 systemd-networkd[773]: sfn0p2.2273     : gained carrier
Jun 07 09:52:21 network[762]: Bringing up interface sfn0p2.2273:  [  OK  ]
Jun 07 09:52:21 systemd-networkd[773]: sfn0p2.2373     : gained carrier
Jun 07 09:52:25 network[762]: Bringing up interface sfn0p2.2373:  [  OK  ]
Jun 07 09:52:25 sm-notify[1464]: Version 1.3.1 starting
Jun 07 09:52:25 crond[1487]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 27% if used.)
Jun 07 09:52:25 crond[1487]: (CRON) INFO (running with inotify support)
Jun 07 09:52:25 sshd[1465]: Server listening on 0.0.0.0 port 22.
Jun 07 09:52:33 ntpdate[1477]: Can't find host time.mycorp.co: Name or service not known (-2)

systemctl enable systemd-networkd-wait-online.service- 已启用,没有帮助。 network-online.target- 还

# systemctl status network-online.target
● network-online.target - Network is Online
   Loaded: loaded (/usr/lib/systemd/system/network-online.target; enabled)
   Active: active since Tue 2016-06-07 09:52:25 EDT; 13min ago
     Docs: man:systemd.special(7)
           http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget

服务文件位于/etc/systemd/system/ntpdate.service

[Unit]
Description=Set time via NTP
After=network-online.target
Before=time-sync.target ntpd.service
Requires=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/ntpdate-wrapper
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

如何ntpdate仅在网络真正可用时才启动此操作?因为如果开始得太早——

Jun 07 09:52:33 ntpdate[1477]: Can't find host time.mycorp.co: Name or service not known (-2)
Jun 07 09:52:33 ntpdate[1477]: no servers can be used, exiting
Jun 07 09:52:33 systemd[1]: ntpdate.service: main process exited, code=exited, status=1/FAILURE
Jun 07 09:52:33 systemd[1]: Failed to start Set time via NTP.
Jun 07 09:52:33 systemd[1]: Dependency failed for Network Time Service Daemon.
Jun 07 09:52:33 systemd[1]: Unit ntpdate.service entered failed state.
Jun 07 09:52:33 systemd[1]: ntpdate.service failed.

相关内容