Centos7.x配置网络
解说
cat /etc/sysconfig/network-scripts/ifcfg-enp6s0 #添加如下内容 BOOTPROTO=static #启用静态IP地址 IPADDR0=192.168.88.10 #设置IP地址 NETMASK=255.255.255.0 #设置子网掩码 GATEWAY0=192.168.88.1 #设置网关 DNS1=8.8.8.8 #设置主DNS DNS2=114.114.114.114 #设置备DNS DEVICE=enp0s3 ONBOOT=yes cat /etc/resolv.conf # Generated by NetworkManager nameserver 192.168.88.1 nameserver 192.168.53.1 #重启网络 service network restart #othre TYPE="Ethernet" BOOTPROTO=static IPADDR0=192.168.0.9 NETMASK=255.255.255.0 GATEWAY0=192.168.0.1 DNS1=8.8.4.4 DNS2=114.114.114.114 DEVICE="eth0" ONBOOT="yes"
eg
cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="none" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="eth0" #UUID="ff71d3b7-aa7d-4ac5-a3ca-87e867fe2a64" DEVICE="eth0" ONBOOT="yes" DNS1="223.5.5.5" DOMAIN="223.5.5.5" IPADDR="192.168.88.50" PREFIX="24" GATEWAY="192.168.88.1" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_PRIVACY="no"
启用/禁用网卡
方式一:ifconfig命令 // 禁用 ifconfig eno16780032 dowm // 启动 ifconfig eno16780032 up 方式一等同于如下: // 禁用 ifdowm eno16780032 // 启动 ifup eno16780032
dns client
1. /etc/sysconfig/network-scripts/ifcfg-eth0 DNS1="223.6.6.6" #前面这个优先级比较高 其实上面不要写上dns更加清爽 2./etc/resolv.conf
troubleshooting
PREFIXO0=24 #设置子网掩码 会导致连上不外网