配置文件
/etc/sysconfig/network-scripts/ifcfg-<interfacename>
静态IP地址配置
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_DISABLED=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=default
NAME=<interface-name>
UUID=<UUID>
DEVICE=<interface-name>
ONBOOT=yes
IPADDR=192.168.100.101
PREFIX=24
GATEWAY=192.168.100.1
这里假设要配置的网络IP地址为192.168.100.101。
动态IP地址配置(网络必须得先有DHCP)
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=eui64
NAME=<interface-name>
UUID=<UUID>
DEVICE=<interface-name>
ONBOOT=yes
重启网络:
$ sudo systemctl restart NetworkManager