虚拟机的网络设置

Posted chen1970

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了虚拟机的网络设置相关的知识,希望对你有一定的参考价值。

安装 好虚拟机,新建CENTOS虚拟机后:

 1.

[[email protected] ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ba:69:7e brd ff:ff:ff:ff:ff:ff
inet 192.168.0.115/24 brd 192.168.0.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::a458:da70:f235:7b27/64 scope link noprefixroute
valid_lft forever preferred_lft forever

如果没有IP地址:配置网络地址和网关 子网掩码

[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# ls
ifcfg-ens33 ifdown-ppp ifup-eth ifup-sit
ifcfg-lo ifdown-routes ifup-ippp ifup-Team
ifdown ifdown-sit ifup-ipv6 ifup-TeamPort
ifdown-bnep ifdown-Team ifup-isdn ifup-tunnel
ifdown-eth ifdown-TeamPort ifup-plip ifup-wireless
ifdown-ippp ifdown-tunnel ifup-plusb init.ipv6-global
ifdown-ipv6 ifup ifup-post network-functions
ifdown-isdn ifup-aliases ifup-ppp network-functions-ipv6
ifdown-post ifup-bnep ifup-routes
[[email protected] network-scripts]# vim ifcfg-ens33

 


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=0e659f14-daa8-48a2-9e3c-91dbfb8fddc1
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.0.116
PREFIX=24
GATEWAY=192.168.0.1
IPV6_PRIVACY=no

2.我用的桥接:配置本机 的域名解析 

[[email protected] network-scripts]# vim /etc/resolv.conf

#Generatedby NetworkManager
search localdomain
nameserver 8.8.8.8
nameserver 8.8.4.4

3.

[[email protected] network-scripts]# ping baidu.com
PING baidu.com (123.125.114.144) 56(84) bytes of data.
64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=2 ttl=52 time=107 ms
64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=3 ttl=52 time=108 ms
^C
--- baidu.com ping statistics ---
4 packets transmitted, 2 received, 50% packet loss, time 3004ms
rtt min/avg/max/mdev = 107.201/107.672/108.143/0.471 ms
[[email protected] network-scripts]#

证明 网络已通

4.用XSHELL连接虚拟,自带的网络YUM源可以用了

 

以上是关于虚拟机的网络设置的主要内容,如果未能解决你的问题,请参考以下文章

vmware15 虚拟机的三种网络设置

S5PV210开发板连接虚拟机的网络设置

关于虚拟机的三种网络模式设置

怎么关闭虚拟机的网络连接

vmware中虚拟机的网络连接设置

虚拟机的网络设置