目录
1、配置网卡
1.1 网卡查看命令:ifconfig -a
[root@centos7-127 ~]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 # 网卡1
inet 192.168.87.127 netmask 255.255.255.0 broadcast 192.168.87.255 # 信息以此为ip地址、网关、广播地址
inet6 fe80::514a:417d:208:cef9 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:05:94:ac txqueuelen 1000 (Ethernet)
RX packets 19263 bytes 21054999 (20.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4260 bytes 385270 (376.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 # 网卡2
inet 192.168.100.1 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::f50c:c73b:7964:13d8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:05:94:b6 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 242 bytes 22731 (22.1 KiB)
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 1000 (Local Loopback)
RX packets 127 bytes 12148 (11.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 127 bytes 12148 (11.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
备注:centos6下一般使用eth开头命名网卡,centos7下一般使用ens开头命名
1.2 网卡配置文件说明
网卡配置文件位置:/etc/sysconfig/network-scripts/ifcfg-ens33 # 网卡ens33的配置文件
网卡配置文件参数:
TYPE=Ethernet # 网络类型:Ethernet以太网
BOOTPROTO=none # 引导协议:自动获取、static静态、none不指定
DEFROUTE=yes # 启动默认路由
IPV4_FAILURE_FATAL=no # 不启用IPV4错误检测功能
IPV6INIT=yes # 启用IPV6协议
IPV6_AUTOCONF=yes # 自动配置IPV6地址
IPV6_DEFROUTE=yes # 启用IPV6默认路由
IPV6_FAILURE_FATAL=no # 不启用IPV6错误检测功能
NAME=eno16777736 # 网卡设备的别名
UUID=90528772-9967-46da-b401-f82b64b4acbc # 网卡设备的UUID唯一标识号
DEVICE=ens33 /# 网卡的设备名称
ONBOOT=yes # 开机自动激活网卡
DNS1=6.6.6.6 # DNS域名解析服务器的IP地址
IPADDR=192.168.87.127 # 网卡的IP地址
PREFIX=24 # 子网掩码
GATEWAY=192.168.87.1 # 默认网关IP地址
GATEWAY=192.168.87.1 # 网关
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
1.3 重启网络服务
centos6下使用 service network restart
centos7下使用systemctl restart network
2、查看确认网卡UUID
2.1 网卡配置文件正常时
在网卡配置文件正常可用的情况下,可以使用nmcli命令查看网卡的UUID和mac地址
[root@centos7-127 ~]# nmcli con show # 查看网卡UUID
NAME UUID TYPE DEVICE
ens33 508e5673-aa9a-4106-9c7b-f1ec838146f7 ethernet ens33
ens37 6e23a9e4-d253-4c66-99d7-996cbf9efd0f ethernet ens37
virbr0 5eaac9f3-fab7-4335-9dba-b6c8d383c3f8 bridge virbr0
有线连接 1 bb84fd2c-7424-3ca9-8746-d61126979b78 ethernet --
[root@centos7-127 ~]# nmcli device show ens33 #查看网卡ens33的信息,包含mac地址
GENERAL.DEVICE: ens33
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:05:94:AC
GENERAL.MTU: 1500
GENERAL.STATE: 100 (连接的)
GENERAL.CONNECTION: ens33
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/6
WIRED-PROPERTIES.CARRIER: 开
IP4.ADDRESS[1]: 192.168.87.127/24
IP4.GATEWAY: 192.168.87.2
IP4.ROUTE[1]: dst = 192.168.87.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.87.2, mt = 100
IP4.DNS[1]: 8.8.8.8
IP4.DNS[2]: 114.114.114.114
IP6.ADDRESS[1]: fe80::514a:417d:208:cef9/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[2]: dst = ff00::/8, nh = ::, mt = 256, table=255
备注: 使用nmcli命令需要先启动NetworkManager,注意大小写systemctl start NetworkManager
2.2 网卡配置文件不可用或者配置文件中UUID错误
使用uuidgen ens33
为ens33生成新的UUID
[root@centos7-127 ~]# uuidgen ens33
ca07653d-2f70-464e-b953-d74694d443b9
然后修改配置文件中的UUID值
重启网络服务systemctl restart network
,完成配置