发布网友 发布时间:2022-04-23 20:19
共3个回答
热心网友 时间:2022-04-20 13:44
我也给一个我的答案,供大家参考
利用ifconfig这个命令就可以显示所有网络相关的基本信息
当然在此基础之上做一些文本处理,就可以直接输出想要
的IP和MAC信息,代码如下
热心网友 时间:2022-04-20 15:02
root@localhostifconfig bond0 | grep "inet6 addr" | awk '{print $3}' |sed 's/\///g'
fe80::2e0:81ff:fec2:12fa
root@localhostifconfig bond0 | grep "net add" | awk '{print $2}' |sed 's/addr://g'
192.168.2.92
root@localhost netstat -an | grep 23 | grep -v LISTEN | wc -l
0
root@localhostlsof -i:23 | grep "in.telnet" | awk '{print $2}'| xargs kill -9
root@localhost
热心网友 时间:2022-04-20 16:37
我给出前三个的答案吧
#!/bin/bash
OUTPUT=jk0701_xxx_ks.txt
/sbin/ifconfig eth0 | sed -n '/inet addr:/ s/inet addr:/IPADDR=/pg' | awk -F" " '{print $1}' >$OUTPUT
/sbin/ifconfig eth0 | sed -n '/HWaddr/ s/^.*HWaddr */HWADDR=/pg' >> $OUTPUT
netstat -an |grep ":23" |grep "ESTABLISHED" | grep -cv "grep" >> $OUTPUT