Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19268732
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类:

2008-05-11 22:22:44

今天,研究了这样一个问题:AIX下,如何判断某个网口是否连接了网线?
    这个例子中,en0没接网线,用如下命令可以帮助判断。


myaix#/> netstat -v en0 | grep -p "Specific Statistics"
2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902) Specific Statistics:
--------------------------------------------------------------------
Link Status : Down
Media Speed Selected: Auto negotiation
Media Speed Running: Unknown
PCI Mode: PCI-X (100-133)
PCI Bus Width: 64-bit
Latency Timer: 144
Cache Line Size: 128
Jumbo Frames: Disabled
TCP Segmentation Offload: Enabled
TCP Segmentation Offload Packets Transmitted: 11
TCP Segmentation Offload Packet Errors: 0
Transmit and Receive Flow Control Status: Enabled
XON Flow Control Packets Transmitted: 0
XON Flow Control Packets Received: 0
XOFF Flow Control Packets Transmitted: 0
XOFF Flow Control Packets Received: 0
Transmit and Receive Flow Control Threshold (High): 45056
Transmit and Receive Flow Control Threshold (Low): 24576
Transmit and Receive Storage Allocation (TX/RX): 16/48

    如果认为某个网口长时间没有收发数据包,就是这个网口没连接网线,那下面的命令也可以。
myaix#/> tcpdump -i en0
tcpdump: listening on en0
^C
0 packets received by filter
0 packets dropped by kernel
myaix#/>

myaix#/> netstat -s -Z -I en1; netstat -s -s -I en1
Name  Mtu   Network     Address            Ipkts Ierrs    Opkts Oerrs  Coll
en1   1500  link#3      0.2.55.2f.74.63          0     0        0     0     0
en1   1500  9.186.183   myaix                    0     0        0     0     0
myaix#/> netstat -s -s -I en1
Name  Mtu   Network     Address            Ipkts Ierrs    Opkts Oerrs  Coll
en1   1500  link#3      0.2.55.2f.74.63          6     0        4     0     0
en1   1500  9.186.183   myaix                    6     0        4     0     0
myaix#/> netstat -s -s -I en0
Name  Mtu   Network     Address            Ipkts Ierrs    Opkts Oerrs  Coll
en0   1500  link#2      0.2.55.2f.74.62          0     0        0     0     0
en0   1500  192.168.0   myaix                    0     0        0     0     0
myaix#/>

    以上命令都可以变通,比如:
netstat -v | grep -p "Specific Statistics"
netstat -I en1; sleep 2; netstat -I en1
netstat -s -Z; netstat -D
netstat -s -s -p ip

阅读(3436) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~