安装 好虚拟机,新建CENTOS虚拟机后:
1.
[root@localhost ~]# 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地址:配置网络地址和网关 子网掩码
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost 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
[root@localhost 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.我用的桥接:配置本机 的域名解析
[root@localhost network-scripts]# vim /etc/resolv.conf
#Generatedby NetworkManager
search localdomain
nameserver 8.8.8.8
nameserver 8.8.4.4
3.
[root@localhost 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
[root@localhost network-scripts]#
证明 网络已通
4.用XSHELL连接虚拟,自带的网络YUM源可以用了