Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15343472
  • 博文数量: 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)

分类: 系统运维

2010-04-20 14:05:50

网线拔掉检测,嵌入式网线直连开发板断电网线拔掉之后,上电仍能自动设置静态ip地址
1.首先设置永久固定静态ip地址
luther@gliethttp:~$ sudo vim /etc/network/interfaces  追加如下内容
auto eth1
iface eth1 inet static
address 192.168.1.249
netmask 255.255.255.0
gateway 192.168.1.1
luther@gliethttp:~$ sudo ifdown eth1   物理禁用网卡
luther@gliethttp:~$ sudo ifup eth1     物理启用网卡
或者
luther@gliethttp:~$ sudo ifdown eth1;sudo ifup eth1
一个网卡如何帮定2个ip地址
luther@gliethttp:~$ sudo vim /etc/network/interfaces
auto eth0:1
iface eth0:1 inet static
address 192.168.1.249
netmask 255.255.255.0
gateway 192.168.1.1
luther@gliethttp:~$ sudo /etc/init.d/networking restart
luther@gliethttp:~$ ifconfig 就可以看到在一个网卡上设置的新ip了
2.安装网线状态变化监控daemon工具软件
luther@gliethttp:~$ sudo apt-get install ifplugd
luther@gliethttp:~$ sudo vim /etc/ifplugd/action.d/ifupdown 该文件是网线拔掉又插上之后还能正常自动设置静态ip的关键,为了能够每次tftp都成功,加入如下一句service xinetd restart
#!/bin/sh
set -e

case "$2" in
up)
    /sbin/ifup $1
    service xinetd restart
    ;;
down)
    /sbin/ifdown $1
    ;;
esac
luther@gliethttp:~$ sudo ifplugd -d 0 -i eth1
luther@gliethttp:~$ sudo ifplugd -k -i eth1 用来停止刚刚给eth1创建的daemon程序
阅读(3970) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~