有时候我们的虚拟机无法ping通网络,今天来总结一下方法
1.虚拟机安装之后,首先要进行网络的虚拟编辑器对网络进行编辑。(编辑nat模式喝DHCP)
2.配置文件的编写
如果想要自动获取IP .需要配置为DHCP
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736 TYPE=Ethernet BOOTPROTO=dhcp 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=15294072-06e3-48d6-91c0-01e732b2a77e DEVICE=eno16777736 ONBOOT=yes #GATEWAY=192.168.253.2 #DNS1=144.144.144.144 #DNS2=8.8.8.8 #NETMASK=255.255.255.0
4.重启网卡
[root@localhost ~]# /etc/init.d/network start
5,查看IP(如果没有出现ip 用dhclient,重新获取一下IP)
[root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:c5:6c:c3 brd ff:ff:ff:ff:ff:ff inet 192.168.253.130/24 brd 192.168.253.255 scope global dynamic eno16777736 valid_lft 1483sec preferred_lft 1483sec inet6 fe80::20c:29ff:fec5:6cc3/64 scope link valid_lft forever preferred_lft foreve6.
6安装ifconfig
[root@localhost ~]# yum install net-tools -y