Ubuntu 设置IP

Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下:

 

# The primary network interface

auto eth0

iface eth0 inet dhcp

设置静态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.0.10

netmask 255.255.255.0

gateway 192.168.0.1

(2)编辑 /etc/resolv.conf,设置dns

nameserver 202.96.134.133

nameserver 202.106.0.20

 

(3)如编辑/etc/resolv.conf无效则编辑如下文件

/etc/resolvconf/resolv.conf.d/head

添加内容

nameserver 202.96.134.133

nameserver 202.106.0.20

 

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

$sudo ifdown eth0

$sudo ifup eth0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值