在线上系统出故障,需远程查看当前设备的网络状态,排查问题,网络抓包分析数据等,本文就介绍了常用的网络调试工具,
一、Linux网络调试命令有哪些?
环境rhel7
1、查看网卡物理连接是否正常
#mii-tool 网卡名
2、查看网卡硬件相关信息
#ethtool 用于查询及设置网卡参数的命令
#ethtool eno16777736
3、配置网络和IP地址
方法一:[root@xuegod72 ~]# nmtui-edit eno33554976
方法二:手工创建一个网卡配置文件
[root@xuegod72 ~]# cp /etc/sysconfig/network-scripts/ ifcfg-eno16777736 ifcfg- eno33554976
[root@xuegod72 network-scripts]# cat ifcfg-eno33554976
方法三:通过命令nmcli来添加
[root@xuegod72 ~]# nmcli con add con-name eno50332200 type ethernet ifname eno5033220 --默认是动态分配IP地址
[root@xuegod72 ~]# nmcli con mod eno50332200 ipv4.method manual --改为手工分配
[root@xuegod72 ~]# nmcli con down eno50332200
[root@xuegod72 ~]# nmcli con up eno50332200 ---重启生效
二、抓包工具
1.tcpdump
示例:#tcpdump port 22 -c 3 -n -S
参数说明:
- port 端口号
- -c 抓几个包
- -n 不解析端口号为协议名
- -S 用绝对而非相对数值列出TCP关联数
- -i 指定网卡
#[root@panda ~]# tcpdump port 22 -c 5 -n -S -i eno16777736
2.wireshark
1、安装
[root@panda ~]# yum -y install wireshark
[root@panda ~]# yum -y install wireshark-gnome.x86_64
2、运行
[root@panda 1.10.14]# wireshark
3、创建一个保存抓包信息的文件
[root@panda test]# touch a.txt
4、执行抓包命令
[root@panda test]# tshark -w a.txt -i eno16777736
[root@panda test]# tshark -r a.txt |more
5、查看抓包内容
总结
本文仅仅简单介绍了常用网络调试命令的使用,网络配置和网络抓包工具的使用。