ITeye博客

ubuntu server静态IP和DNS服务器设置

cduym · 2012-12-22 22:46 · Linux · 操作系统 · Markdown

Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,动态IP获取。

设置静态ip的方法如下:
1) 编辑 /etc/network/interfaces
1.1)将dhcp 一行屏蔽

# The primary network interface
auto eth0
#iface eth0 inet dhcp

 

1.2)添加和静态ip有关的参数

# The primary network interface
iface eth0 inet static
address 192.168.1,151
netmask 255.255.255.0
gateway 192.168.1.1

2)编辑 /etc/resolv.conf,设置dns,如果重启还原,则还需要修改/etc/resolvconf/resolv.conf.d/base文件,两个内容一样

nameserver 192.168.1.1 #路由网关
nameserver 8.8.8.8 #google的dns服务器

3)执行下面两个命令,启用新设置

$sudo ifdown eth0
$sudo ifup eth0

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。