Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15314854
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2009-05-13 15:26:38

网线拔掉检测,嵌入式网线直连开发板断电网线拔掉之后,上电仍能自动设置static静态ip地址

可以
luther@gliethttp:~$ man interfaces
luther@gliethttp:~$ vim /usr/share/doc/ifupdown/examples
来看到/etc/network/interfaces配置样例,
不知道为什么,使用GUI设置的static ip地址当重新启动电脑之后,就又恢复到了dhcp获取,
很是恼人,现在我们来手动配置ip,gateway和dns
luther@gliethttp:~$ sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.23.23
netmask 255.255.255.0
gateway 192.168.23.1

luther@gliethttp:~$ sudo ifdown eth1   物理禁用网卡
luther@gliethttp:~$ sudo ifup eth1     物理启用网卡
或者
luther@gliethttp:~$ sudo ifdown eth1;sudo ifup eth1

接下来添加DNS
luther@gliethttp:~$ cat /etc/resolv.conf
# Generated by NetworkManager // 需要删除改行,否则每次重启ubuntu之后,/etc/resolv.conf将被清空
luther@gliethttp:~$ sudo vim /etc/resolv.conf
nameserver 202.106.0.20

luther@gliethttp:~$ sudo /etc/init.d/networking restart
或者
luther@gliethttp:~$ sudo service networking restart

如果配置失败,可以使用手工配置方法:
luther@gliethttp:~$ sudo ifconfig eth0 192.168.23.23 netmask 255.255.255.0 up
luther@gliethttp:~$ sudo route add default gw 192.168.23.1 eth0
阅读(6789) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~