V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
cattyhouse
V2EX  ›  Linux

被 systemd-networkd.service 害死了

  •  1
     
  •   cattyhouse · 2015-04-27 23:55:18 +08:00 · 11676 次点击
    这是一个创建于 3304 天前的主题,其中的信息可能已经有所发展或是发生改变。
    因为用的Archlinux,默认systemd启用,所以干脆用 systemd-networkd.service来管理DHCP获取ip地址,抛弃了[email protected],ip地址是配置成功了,但是坑爹的是原本可以用的vpn服务突然连接不上了,取消 systemd-networkd.service换回[email protected]之后,一切都顺畅了。 摸索了好久,发现原来如此坑爹。。。

    官网上: 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

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