ifconfig 查看网络接口名称

编辑 /etc/network/interfaces,内容按需修改,如:

auto lo
iface lo inet loopback

auto eol0 #eol0网卡名
iface eol0 inet static
address 122.224.146.29
netmask 255.255.255.128
gateway 122.224.146.1

刷新网络:

sudo ip addr flush eol0
sudo systemctl restart networking

如果出现报错,查看状态: systemctl status network.service,内容如:

  ● network.service - LSB: Bring up/down networking
  Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
  Active: failed (Result: exit-code) since 二 2020-12-15 19:01:47 CST; 1min 16s ago
  Docs: man:systemd-sysv-generator(8)
  Process: 4681 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
  CGroup: /system.slice/network.service
  └─1192 /sbin/dhclient -H mini1 -1 -q -lf /var/lib/dhclient/dhclient--ens33.lease -pf /v...
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
  12月 15 19:01:47 mini1 systemd[1]: network.service: control process exited, code=exited status=1
  12月 15 19:01:47 mini1 systemd[1]: Failed to start LSB: Bring up/down networking.
  12月 15 19:01:47 mini1 systemd[1]: Unit network.service entered failed state.

其原因是,与 NetworkManager 服务有冲突,解决办法如:

#关闭NetworkManager
sudo systemctl stop NetworkManager 
#关闭开机启动NetworkManager
sudo systemctl disable NetworkManager.service
#重启系统
sudo reboot
Last modification:December 16th, 2020 at 10:48 am