配置静态IP
查看自己所有的网络名称
ip addr
 编辑文件 /etc/network/interfaces,内容如下:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
#auto ens33 #设置开机自动连接网络
#iface ens33 inet loopback
allow-hotplug ens33
#static表示使用固定IP地址上网,dhcp表示使用动态ip
iface ens33 inet static
#设置静态ip地址
address 192.168.198.131
#子网掩码
netmask 255.255.255.0
#网关
gateway 192.168.198.2
网关和子网掩码等信息 可以打开虚拟机的网络编辑器查看
  这个文件改动之后,应该重启网络:
/etc/init.d/networking restart
这个时候 执行 ifconfig 就可以查看所配置的ip ,如果不展示的话 就reboot 重启下
配置DNS
 
ping www.baidu.com
PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data.
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=1 ttl=128 time=17.3 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=2 ttl=128 time=7.35 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=3 ttl=128 time=12.3 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=4 ttl=128 time=19.2 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=5 ttl=128 time=34.3 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=6 ttl=128 time=12.5 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=7 ttl=128 time=30.9 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=8 ttl=128 time=6.59 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=9 ttl=128 time=112 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=10 ttl=128 time=8.06 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=11 ttl=128 time=49.1 ms
|