VM12中CentOS7以NAT方式连接网络的方法

解决问题:centos网络连不上,连不上主机,ifconfig等命令不能用(配完有网了,安装上就好了)等问题

前提:安装vm12,centos7(最小安装) 

注意:以下以192开头的,你都要替换成自己的,可在vm中找到(192.168.181.66:我自己设的ip,192.168.181.2:网关)

VM12中CentOS7以NAT方式连接网络的方法

(1)配置eno16777736(/etc/sysconfig/network-scripts/ifcfg-eno16777736),
#配置开始#
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=4ee0a1dd-fd55-4a2c-acb3-732bf9766e04
DEVICE=eno16777736
ONBOOT=yes
IPADDR0=192.168.181.66
PREFIX0=24
GATEWAY0=192.168.181.2
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS2=114.114.114.114
#配置结束#

(2)配置DNS步骤1(/etc/NetworkManager/NetworkManager.conf ),
#配置开始#
# Configuration file for NetworkManager.
#
# See "man 5 NetworkManager.conf" for details.
#
# The directory /etc/NetworkManager/conf.d/ can contain additional configuration
# snippets. Those snippets override the settings from this main file.
#
# The files within conf.d/ directory are read in asciibetical order.
#
# If two files define the same key, the one that is read afterwards will overwrite
# the previous one.
[main]
plugins=ifcfg-rh
dns=none
[logging]
#level=DEBUG
#domains=ALL
#配置结束#

(3)配置DNS步骤2(/etc/resolv.conf),
#配置开始#
nameserver 8.8.8.8
nameserver 114.114.114.114
#配置结束#

(4)注意网络是以NAT模式而不是桥接模式,注意配置完重启(systemctl restart network)


@Arya0624
上一篇:【Java 进阶篇】【第一课】String类


下一篇:8.6 C++文本文件的读写操作