Ubuntu Server 配置网络

------------------

  Ubuntu 14.04   x86_64

 

-----------------

 

设置静态IP:
vi /etc/network/interfaces.

然后再编辑

auto lo
iface lo inet loopback

# The primary network interface
auto em1  ##第一块网卡的名称 , 可以通过ifconfig命令去查找
iface em1 inet static  ## 设置为静态IP
        address 192.xx.yy.zz  #你的IP地址

        netmask 255.255.255.0 ##子网掩码
        network 192.xx.yy.0 ###
        broadcast 192.xx.yy.255 # 广播
        gateway 192.xx.yy.254  ## 默认网关

        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8  ##域名解析服务器地址

按照以上的格式编辑之后就可以保存退出了.

例如:

 

image

 

sudo /etc/init.d/networking restart

这句话执行之后,最好在查看是否执行成功: echo $?

如果输出的值不是0 ,说明执行失败。 尝试使用一下方式:

 

关闭网络:

ifdown <网卡名称>

打开网络:

ifup <网卡名称>

 

实在不行就重新启动系统:

sudo  reboot –h now

 


posted @ 2016-11-22 11:10  修雨轩陈  阅读(449)  评论(0编辑  收藏  举报