1、centos网卡
1.1 位置
vim /etc/sysconfig/network-scripts/ifcfg-ens33
js
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
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="ens33"
UUID="8b22f41e-70f1-4eda-a423-d1e8f1cbf37b"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.107.190
NETMASK=255.255.255.0
GATEWAY=192.168.107.2
DNS1=218.2.135.1
DNS2=8.8.8.8
ifconfig
查看具体配置
js
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.107.190 netmask 255.255.255.0 broadcast 192.168.107.255
inet6 fe80::77f1:d253:9067:dd77 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:09:f6:26 txqueuelen 1000 (Ethernet)
RX packets 824464 bytes 1176798378 (1.0 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 340528 bytes 20806831 (19.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 47096 bytes 4113936 (3.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 47096 bytes 4113936 (3.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:a5:b3:e9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
systemctl restart network
重启网卡配置文件
2、Ubuntu网卡
2.1 配置文件位置
vim /etc/netplan/00-installer-config.yaml
js
network:
version: 2
ethernets:
ens33:
dhcp4: no
addresses: [192.168.107.180/24]
gateway4: 192.168.107.2
nameservers:
addresses: [8.8.8.8,114.114.114.114]
注意:Ubuntu网卡配置文件为yaml文件的格式,要严格注意缩进与空格
ubuntu重启网络网卡的命令
root@ubuntu:/etc/apt# netplan apply