前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ubuntu 13.04 设定静态IP

ubuntu 13.04 设定静态IP

作者头像
随机来个数
发布2018-04-16 15:39:52
8280
发布2018-04-16 15:39:52
举报
文章被收录于专栏:写代码的海盗写代码的海盗

切换到root用户,然后进入/etc/network目录。备份interfaces文件(备份文件是一个好习惯)

下面编辑interfaces文件,添加如下语句:

代码语言:javascript
复制
1 # Assgin static IP by eric on 26-SEP-2012
2 iface eth0 inet static
3 address 192.168.196.135         #change to your static IP
4 netmask 255.255.255.0           #change to your netmask
5 gateway 192.168.196.255         #change to your getway
6 #We must specify dns-nameserver here
7 #in order to get internet access from host
8 dns-nameservers 192.168.196.255
9 auto eth0

编辑完成后的interfaces文件内容如下:

代码语言:javascript
复制
root@ubuntu:/etc/network# cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#add by andy at 2014-08-14
# Assgin static IP by eric on 26-SEP-2012
iface eth0 inet static
address 192.168.196.135         #change to your static IP
netmask 255.255.255.0           #change to your netmask
gateway 192.168.196.255         #change to your getway
#We must specify dns-nameserver here
#in order to get internet access from host
dns-nameservers 192.168.196.255
auto eth0

下一步就是重启网卡:

代码语言:javascript
复制
root@ubuntu:/etc/network# /etc/init.d/networking restart

重启完成后,测试一下:

代码语言:javascript
复制
 root@ubuntu:/etc/network# ping www.baidu.com.cn
 PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
 64 bytes from 220.181.112.244: icmp_req=1 ttl=128 time=6.12 ms
 64 bytes from 220.181.112.244: icmp_req=2 ttl=128 time=14.7 ms

OK。静态IP设置完成。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-08-14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档