Ubuntu 16.04网络配置(静态IP)

打开虚拟机编辑/etc/network/interfaces文件

root@swift:/home/swift# cat /etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto ens33#16.04的命名为ens33不是eth0

iface ens33 inet static#static表示静态

address 192.168.110.111    #IP地址

netmask 255.255.255.0    #子网掩码

gateway 192.168.110.2    #网关

dns-nameservers 61.139.2.69    #DNS

root@swift:/home/swift# /etc/init.d/networking restart

[ ok ] Restarting networking (via systemctl): networking.service.

root@swift:/home/swift#ping -c 4 www.baidu.com

PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.

64 bytes from 180.97.33.108: icmp_seq=1 ttl=128 time=51.1 ms

64 bytes from 180.97.33.108: icmp_seq=2 ttl=128 time=48.9 ms

64 bytes from 180.97.33.108: icmp_seq=3 ttl=128 time=49.4 ms

64 bytes from 180.97.33.108: icmp_seq=4 ttl=128 time=51.3 ms

--- www.a.shifen.com ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3006ms

rtt min/avg/max/mdev = 48.966/50.215/51.304/1.041 ms

root@swift:/home/swift#

到此配置完成可以连接网络进行安装和更新了。

如果重启服务后还是不能连接网络

编辑/etc/resolvconf/resolv.conf.d/目录下的base  head两个文件

在末尾追加DNS

例如:

nameserver 61.139.2.69#使用当地网络服务商提供的DNS

修改后重启网络服务或重启虚拟机(reboot、init 6、shutdown -r now等多种方法)。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ping ping send ICMP ECHO_REQUEST to network hostsbetter t...
    BlackChen阅读 20,195评论 0 10
  • 目的 使用网桥模式,将多台linux虚拟机/物理主机桥接。同时保证虚拟机和宿主机器及局域网内其他主机进行通信。最后...
    W_Bousquet阅读 3,739评论 0 1
  • ping error: Destination off-link but no route作者 codercjg ...
    codercjg阅读 1,073评论 0 1
  • 本文整理了在实践过程中使用的Linux网络工具,这些工具提供的功能非常强大,我们平时使用的只是冰山一角,比如lso...
    老夫刘某阅读 3,616评论 0 7
  • 小麦爸爸是个重情义的人,心里一直惦记着这一家三口,托人四处打听。后来听说他们搬去了S市,在那儿又干起了老本行,种蔬...
    Williamlora阅读 246评论 0 0