标签:pack 接口 -- host 1.5 service static 重启 ipaddr
直接在linux系统下,编辑修改如下文件:
//编辑文件/etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost install]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 //查看文件/etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost install]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.20.129 NETMASK=255.255.255.0 GATEWAY=192.168.20.2 DNS1=101.198.199.200 DNS2=114.114.114.114 //重启网卡 [root@localhost install]# service network restart 正在关闭接口 eth0: [确定] 关闭环回接口: [确定] 弹出环回接口: [确定] 弹出界面 eth0: [确定] //尝试ping主机 [root@localhost install]# ping 192.168.1.125 PING 192.168.1.125 (192.168.1.125) 56(84) bytes of data. 64 bytes from 192.168.1.125: icmp_seq=1 ttl=128 time=0.893 ms 64 bytes from 192.168.1.125: icmp_seq=2 ttl=128 time=0.747 ms 64 bytes from 192.168.1.125: icmp_seq=3 ttl=128 time=0.583 ms ^C --- 192.168.1.125 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2952ms rtt min/avg/max/mdev = 0.583/0.741/0.893/0.126 ms //尝试ping外网百度 [root@localhost install]# ping www.baidu.com PING www.a.shifen.com (115.239.211.112) 56(84) bytes of data. 64 bytes from 115.239.211.112: icmp_seq=1 ttl=128 time=42.6 ms 64 bytes from 115.239.211.112: icmp_seq=2 ttl=128 time=39.1 ms ^C --- www.a.shifen.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1653ms rtt min/avg/max/mdev = 39.128/40.876/42.625/1.760 ms
DNS一定要和主机的一样,如下图:
//编辑文件/etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost install]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 //查看文件/etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost install]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost install]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_PEERDNS=no IPV6_PEERROUTES=no IPV6_FAILURE_FATAL=no NAME=eth0 UUID=17c77773-bc60-40d0-b4e3-e9f22ca1841b DEVICE=eth0 ONBOOT=yes IPADDR=192.168.20.129 PREFIX=24 GATEWAY=192.168.20.2 DNS1=101.198.199.200 DNS2=114.114.114.114 HWADDR="00:0C:29:0B:91:B7"
UUID的获取:
[root@localhost install]# uuidgen eth0
17c77773-bc60-40d0-b4e3-e9f22ca1841b
HWADDR的获取:
这下就能虚拟机完美上网了:
标签:pack 接口 -- host 1.5 service static 重启 ipaddr
原文地址:https://www.cnblogs.com/mmzs/p/9488213.html