ubuntu网络配置
Nov 7, 2015 · 1 minute read · Commentsubuntunetwork
Ubuntu配置网络静态IP
Ubuntu网络配置文件是在/etc/network/interfaces
>默认文件
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
如果我们想要配置静态IP可以这样:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
#iface lo inet loopback
# The primary network interface #此行注释掉
auto eth0
iface eth0 inet static #将"dhcp"修改为"static"
address 10.0.0.125 #增加下面三行
gateway 10.0.0.2
netmask 255.255.255.0
配置DNS,在/etc/resolv.conf文件中
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.0.2
重启服务器。
Ubuntu 14.04 重启后DNS配置丢失问题的解决方案
每次修改DNS配置文件 /etc/resolv.conf 重启后就会失效。从网上查知,这个文件是动态创建,所以每次重启都会被重写。
更改方式有以下两种如下:
1.
vi /etc/network/interfaces
dns-nameservers 8.8.8.8
2.
vi /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 114.114.114.114
保存,然后执行:resolvconf -u
。
重启之后,/etc/resolv.conf里面的内容被加载成了base中的数据。
所以到此为止成功解决了重启后DNS配置丢失的问题。