Donnie

不积跬步无以至千里

VirtualBox克隆Centos7.6后修改静态ip异常

一,修改静态ip启动异常

异常如下


    [root@localhost network-scripts]#  systemctl restart network
    Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
    [root@localhost network-scripts]# 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 Wed 2019-04-10 11:06:17 CST; 8s ago
         Docs: man:systemd-sysv-generator(8)
    TYPE="Ethernet"
      Process: 7025 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
    
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain network[7025]: RTNETLINK answers: File exists
    Apr 10 11:06:17 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
    Apr 10 11:06:17 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
    Apr 10 11:06:17 localhost.localdomain systemd[1]: Unit network.service entered failed state.
    Apr 10 11:06:17 localhost.localdomain systemd[1]: network.service failed.

二,原因

网卡配置名不统一,如下几图


三,统一配置名称并修改静态ip

  1. cd /etc/sysconfig/network-scripts/

  2. mv ifcfg-ens160 ifcfg-enp0s3

  3. vi ifcfg-enp0s3


    TYPE="Ethernet"
    PROXY_METHOD="none"
    BROWSER_ONLY="no"
    BOOTPROTO="static" #静态IP
    DEFROUTE="yes"
    IPV4_FAILURE_FATAL="yes"
    IPV6INIT="yes"
    IPV6_AUTOCONF="yes"
    IPV6_DEFROUTE="yes"
    IPV6_FAILURE_FATAL="no"
    IPV6_ADDR_GEN_MODE="stable-privacy"
    UUID="da69ad28-4fc3-4858-972d-0455ac92d569"
    PREFIX="24"
    IPV6_PRIVACY="no"
    NAME="enp0s3"  #都需要保持一致,不然会出现重启异常
    DEVICE="enp0s3" #
    ONBOOT="yes" #开机启动
    IPADDR="192.168.1.17" #本机地址
    GATEWAY="192.168.1.1"  #默认网关
    NETMASK=255.255.255.0 #子网掩码

4.再重启 systemctl restart network

赞赏支持