被 systemd-networkd.service 害死了

2015-04-27 23:55:18 +08:00
 cattyhouse
因为用的Archlinux,默认systemd启用,所以干脆用 systemd-networkd.service来管理DHCP获取ip地址,抛弃了dhcpcd@.service,ip地址是配置成功了,但是坑爹的是原本可以用的vpn服务突然连接不上了,取消 systemd-networkd.service换回dhcpcd@.service之后,一切都顺畅了。 摸索了好久,发现原来如此坑爹。。。

官网上: http://www.freedesktop.org/software/systemd/man/systemd.network.html
里面有一句:

IPForward=
Configures IP forwarding for the network interface. If enabled incoming packets on the network interface will be forwarded to other interfaces according to the routing table. Takes either a boolean argument, or the values "ipv4" or "ipv6", which only enables IP forwarding for the specified address family. This controls the net.ipv4.conf.<interface>.forwarding and net.ipv6.conf.<interface>.forwarding sysctl options of the network interface (see ip-sysctl.txt for details about sysctl options). Defaults to "no".

Note: unless this option is turned on, no IP forwarding is done on this interface, even if this is globally turned on in the kernel, with the net.ipv4.ip_forward and net.ipv4.ip_forward sysctl options. Also, if this option is enabled for at least one interface, the global options in the kernel are also enabled as necessary, to ensure IP forwarding can take place.

IPMasquerade=
Configures IP masquerading for the network interface. If enabled packets forwarded from the network interface will be appear as coming from the local host. Takes a boolean argument. Implies IPForward=yes. Defaults to "no".


特别是这句话:


Note: unless this option is turned on, no IP forwarding is done on this interface, even if this is globally turned on in the kernel, with the net.ipv4.ip_forward and net.ipv4.ip_forward sysctl options.

也就是说,如果用systemd-networkd.service来配置ip地址,而且没有开启 IPForward=1 这个选项的话,ip转发就会失效(即使sysctl.conf里面配置了转发,systemd也会让它失效),也就意味着VPN能拨号,但是不能上网。

我真搞不明白,systemd到底要干什么。。。 原来的系统服务什么都被他给替代了。。。

另外有些程序需要系统获取ip地址之后才能够正常运行。。。 如果用systemd-networkd.service 配置网络,他是不管你ip地址有没有,就直接往下继续运行其他service,导致出问题。除非enable systemd-networkd-wait-online.service,而且还要给service特别设置

[Unit]
Requires=network-online.target
After=network-online.target

尤其影响的是openvpn@.service strongswan@.service.
11692 次点击
所在节点    Linux
16 条回复
efi
2015-04-27 23:57:00 +08:00
LOL 你们阿吃粉不是也是systemd教徒么
sdysj
2015-04-28 00:06:42 +08:00
Arch 过渡 Gentoo 一身轻松,以前用 Arch 的时候 每次 systemd 都坑爹死,还有那个 service 写法又太另类了。
enotx
2015-04-28 00:31:13 +08:00
@efi
不要污蔑!原教旨的Arch教徒是崇尚BSD style init的!
ryd994
2015-04-28 02:44:35 +08:00
明显是你们信仰不够!
圣经要认真读: http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
PS:systemd没想干什么奇怪的事情,只是想统治世界而已
kn007
2015-04-28 08:04:06 +08:00
我是过来看热闹的
ety001
2015-04-28 08:10:03 +08:00
上次配置aria2c,已经被坑过了。。。就是因为不管获没获取到ip,都继续执行,导致启动到aria2c的时候就出错了。。。
zent00
2015-04-28 08:42:56 +08:00
@efi 我还是爱以前的 rc.conf
ytjfmv
2015-04-28 08:48:07 +08:00
@ryd994 systemd的作者以前也干过不少类似给人找麻烦的事情
mcfog
2015-04-28 08:52:58 +08:00
反正之前一装centos7发现自己wifi都不会连了… 所以说就是新版“新特性”老这么坑大家才不愿意升级的啊
ytjfmv
2015-04-28 08:58:34 +08:00
@mcfog 其实新的方式是更合理的,比如楼主的例子,网卡相关的配置就应该放在网卡配置文件里面
FifiLyu
2015-04-28 09:02:16 +08:00
仅仅是因为新东西不习惯而已。我Arch上也被坑过。不过,解决了就好。
mcfog
2015-04-28 09:03:46 +08:00
@ytjfmv 问题是习惯的迁移是要时间的,在原有的配置文件注释里写上caution,保留原有的工具(但输出deprecated警告)才是正道。但由于种种原因,各个发行版在这方面做的都不咋地
ytjfmv
2015-04-28 09:09:14 +08:00
@mcfog 楼主这个例子这是systemd的问题,systemd不应该在本身没有配置的情况下去覆盖sysctl的配置,它这就是强制大家用它的配置,和强奸udev的方式是一模一样的。
cattyhouse
2015-04-28 12:03:30 +08:00
@ytjfmv 你是个明白人,其他评论都是在瞎掰。
johnsmith123
2015-04-28 13:04:13 +08:00
本来就是一堆想要创新的程序员的产物,哪会适合运维,我这现在还有人用/etc/rc.d的方式重启应用
crysislinux
2015-04-28 15:30:55 +08:00
我就说我的vpn怎么连得上但是上不了网。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/186840

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX