配置静态IP连接外网,首先设为桥接模式
虚拟机》设置
编辑》虚拟机编辑器
切换到root用户,输入密码
su root
修改配置文件
[root@localhost /]# vi etc/sysconfig/network-scripts/ifcfg-ens33
修改:ins键或i键
退出不保存:esc键+:+q!
保存修改退出:esc+:+wq
改完后如下
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="67d82594-f3e0-41c5-86f5-13d1221a7e51"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.13.206"
NETMASK="255.255.0.0"
DNS1=114.114.114.114
GATEWAY=192.168.13.1
PEERDNS="yes"
PEERROUTES="no"
重启network服务
[root@localhost network-scripts]# service network restart
Restarting network (via systemctl): [ 确定 ]
连接外网
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=1 ttl=54 time=130 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=2 ttl=54 time=130 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=3 ttl=54 time=143 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=4 ttl=54 time=141 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=5 ttl=54 time=127 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=6 ttl=54 time=139 ms
64 bytes from 180.97.33.107 (180.97.33.107): icmp_seq=7 ttl=54 time=134 ms
ctrl+c键退出ping状态
来源:CSDN
作者:HansScopion
链接:https://blog.csdn.net/qq_29410905/article/details/84872590