Linux netstat命令详解

netstat命令用于显示各种网络相关信息。如网络连接,路由表,接口状态(Interface Statistics),masquerade连接,多播成员(Multicast Memberships)等。

常见参数:

-a 显示所有选项,默认不显示LISTEN相关信息

-t 仅显示tcp相关选项

-u 仅显示udp相关选项

-n 拒绝显示别名,能显示数字的全部转化成数字

-l 仅列出有在Listen(监听)的服务状态

-p 显示建立相关的程序名

-r 显示路由信息,路由表

-e 显示扩展信息

-s 按各个协议进行统计

-c 每隔一个固定时间,执行该netstat命令

提示:LISTEN各LISTENING的状态只有用-a或-l才能看到

[[email protected] ~]# netstat -a   //列出所有端口(包括监听和未监听的)
[[email protected] ~]# netstat -atu  //列出所有tcp和udp端口
[[email protected] ~]# netstat -lx   //列出所有监听UNIX端口
[[email protected] ~]# netstat -sut  //显示tcp和udp的统计信息
[[email protected] ~]# netstat -rn   //显示路由表
[[email protected] ~]# netstat -tlnp|grep httpd  
[[email protected] ~]# netstat -i  //显示网络接口列表
[[email protected] ~]# netstat -ie //显示与ifconfig一样的信息

ifconfig命令

[[email protected]002 yum.repos.d]# ifconfig
[[email protected] yum.repos.d]# ifdown ens33;ifup ens33  //重启某一个网卡
[[email protected] yum.repos.d]# systemctl restart network  //重启网卡

给一个网卡设定多个ip

[[email protected] network-scripts]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens33:1
[[email protected] network-scripts]# vi ifcfg-ens33:1

linux-网络状态

[[email protected] network-scripts]# ifdown ens33;ifup ens33

linux-网络状态

查看网卡连接状态

[[email protected] ~]# mii-tool ens33
ens33: negotiated 1000baseT-FD flow-control, link ok
[[email protected] ~]# ethtool ens33
Settings for ens33:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: off (auto)
	Supports Wake-on: d
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes


转载于:https://blog.51cto.com/13480443/2072088

相关文章: