NAT模式相当于宿主机内部的一个虚拟网络,与宿主机公用一个IP.桥接相当于和宿主机平行,独立的IP和网卡.
1 设置开机自启
# vi /etc/sysconfig/network-scripts/ifcfg-ens33
将no改为yes
# ONBOOT=yes
# systemctl restart network #重启网络
2 下载网络工具
如果有就不需要安装了
# yum install net-tools
3 查看网卡信息
# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.31.132 netmask 255.255.255.0 broadcast 192.168.31.255
inet6 fe80::928c:470b:c58a:906b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d8:cb:ba txqueuelen 1000 (Ethernet)
RX packets 25785 bytes 35787047 (34.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14758 bytes 925754 (904.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
其中ip地址是 192.168.31.132,掩码是255.255.255.0,mac地址是00:0c:29:d8:cb:ba
在看一下网关地址,网络管理->NAT设置->网关地址
4 将网卡信息录入到配置文件中
# vi /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=本机分配的ip地址
GATEWAY=网关
DNS1=114.114.114.114
NETMASK=子网掩码
HWADDR=mac地址
# systemctl restart network
# ping www.baidu.com
标签:network,Centos,ip,虚拟机,宿主机,192.168,网卡,地址
From: https://www.cnblogs.com/JQL-blog/p/18132066