您尚未登录。

#1 2015-05-14 21:13:56

atmouse
会员
注册时间: 2011-08-24
帖子: 701

systemd.network设置静态路由时无效

systemd-networkd可以通过下面这个配置项给网卡设置静态路由
[ROUTE] SECTION OPTIONS
       The "[Route]" section accepts the following keys. Specify several "[Route]" sections to configure several routes.

但是如果网卡设置成DHCP的时候,并不是马上就可以获取到ip,这时候上面设置的配置就会错误,问题是systemd-networkd没有在dhcp获取到ip后重新ip route设置路由
看日志前两行


May 14 19:10:11 ArchCC systemd-networkd[364]: wlan0           : wlan0           : could not set route: Network is unreachable
May 14 19:10:11 ArchCC systemd-networkd[364]: wlan0           : wlan0           : could not set route: Network is unreachable
May 14 19:10:11 ArchCC systemd[1]: Started Network Name Resolution.
May 14 19:10:11 ArchCC sshd[370]: Server listening on 0.0.0.0 port 22.
May 14 19:10:11 ArchCC sshd[370]: Server listening on :: port 22.
May 14 19:10:11 ArchCC systemd[1]: Reached target Multi-User System.
May 14 19:10:11 ArchCC systemd[1]: Startup finished in 4.174s (kernel) + 1.534s (userspace) = 5.708s.
May 14 19:10:11 ArchCC systemd[1]: Starting Multi-User System.
May 14 19:10:11 ArchCC wpa_supplicant[352]: Could not read interface p2p-dev-wlan0 flags: No such device
May 14 19:10:13 ArchCC kernel: cfg80211: Calling CRDA to update world regulatory domain
May 14 19:10:14 ArchCC kernel: cfg80211: Calling CRDA to update world regulatory domain
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: SME: Trying to authenticate with 78:24:af:e6:41:14 (SSID='LYDD-5G' freq=5765 MHz)
May 14 19:10:15 ArchCC kernel: wlan0: authenticate with 78:24:af:e6:41:14
May 14 19:10:15 ArchCC kernel: wlan0: send auth to 78:24:af:e6:41:14 (try 1/3)
May 14 19:10:15 ArchCC kernel: wlan0: authenticated
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: Trying to associate with 78:24:af:e6:41:14 (SSID='LYDD-5G' freq=5765 MHz)
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: Associated with 78:24:af:e6:41:14
May 14 19:10:15 ArchCC kernel: wlan0: associate with 78:24:af:e6:41:14 (try 1/3)
May 14 19:10:15 ArchCC kernel: wlan0: RX AssocResp from 78:24:af:e6:41:14 (capab=0x1011 status=0 aid=1)
May 14 19:10:15 ArchCC kernel: wlan0: associated
May 14 19:10:15 ArchCC kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-STARTED EAP authentication started
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=4 -> NAK
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=25
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 0 method 25 (PEAP) selected
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-PEER-CERT depth=1 subject='/C=FR/ST=Radius/L=Somewhere/O=Example Inc./emailAddress=admin@example.com/CN=Example Certificate 
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-PEER-CERT depth=0 subject='/C=FR/ST=Radius/O=Example Inc./CN=Example Server Certificate/emailAddress=admin@example.com' hash
May 14 19:10:15 ArchCC wpa_supplicant[352]: EAP-MSCHAPV2: Authentication succeeded
May 14 19:10:15 ArchCC wpa_supplicant[352]: EAP-TLV: TLV Result - Success - EAP-TLV/Phase2 Completed
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: WPA: Key negotiation completed with 78:24:af:e6:41:14 [PTK=CCMP GTK=CCMP]
May 14 19:10:15 ArchCC wpa_supplicant[352]: wlan0: CTRL-EVENT-CONNECTED - Connection to 78:24:af:e6:41:14 completed [id=0 id_str=]
May 14 19:10:15 ArchCC systemd-networkd[364]: wlan0           : Gained carrier
May 14 19:10:15 ArchCC systemd-networkd[364]: wlan0           : DHCPv4 address 192.168.254.25/24 via 192.168.254.252
May 14 19:10:15 ArchCC dbus[356]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service'
May 14 19:10:15 ArchCC systemd-networkd[364]: wlan0           : Configured
May 14 19:10:15 ArchCC systemd-timesyncd[342]: Network configuration changed, trying to establish connection.
May 14 19:10:15 ArchCC systemd-timesyncd[342]: Network configuration changed, trying to establish connection.


当一切都启动好后,我再systemctl restart systemd-networkd 路由就可以设置成功

离线

#2 2015-05-15 19:34:57

atmouse
会员
注册时间: 2011-08-24
帖子: 701

Re: systemd.network设置静态路由时无效

没人能解决么? 我英语不行不想发英文论坛

离线

#3 2015-05-15 22:25:00

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 6,284
个人网站

Re: systemd.network设置静态路由时无效

我不用 systemd-networkd 的。你试试在联网之后再用一个服务设置路由呢?

离线

页脚