您尚未登录。

#1 2017-01-01 21:10:03

JingJingHack
会员
注册时间: 2017-01-01
帖子: 2

用systemd找不到网卡接口?

这是AutoExec.service文件:

[Uinit]
Description=AutoExec
Wants=network.target
Before=network.target

[Service]
Type=oneshot
ExecStart=/root/conncet_network

[Install]
WantedBy=multi-user.target

这是connect_network文件:

#!/bin/bash
ifconfig ens3 up
ifconfig ens3 160.16.116.238
route add default gw 160.16.116.1
echo 'nameserver 8.8.8.8' >> /etc/resolv.conf

窝把AutoExec加到了multi-user.target.wants里。
重启之后运行systemctl status AutoExec,输出:
image
但是开机后直接运行systemctl start AutoExec一切正常。

最近编辑记录 JingJingHack (2017-01-01 21:15:05)

离线

#2 2017-01-01 22:35:29

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

Re: 用systemd找不到网卡接口?

执行得太早了。你依赖一下 device unit 吧,比如 {After,Requires}=sys-subsystem-net-devices-ens3.device。

离线

#3 2017-01-02 10:35:37

JingJingHack
会员
注册时间: 2017-01-01
帖子: 2

Re: 用systemd找不到网卡接口?

依云 说:

执行得太早了。你依赖一下 device unit 吧,比如 {After,Requires}=sys-subsystem-net-devices-ens3.device。

谢谢乃,通过乃的方法已经解决。话说居然在这里遇见乃,真是缘分啊。

离线

#4 2017-01-02 18:56:16

zsrkmyn
lazy...
注册时间: 2013-05-05
帖子: 331

Re: 用systemd找不到网卡接口?

为什么不用 netctl 之类的工具来管理网络呢? 0.0

离线

页脚