通过以下命令,可以按网段ping所有的主机,并返回那些ip状态为在线,前提是安装nmap

命令:

  nmap -sP 220.181.38.0/24

运行结果如下:

	➜  ~ nmap -sP 220.181.38.0/24
	
	Starting Nmap 6.40 ( http://nmap.org ) at 2021-06-26 11:27 CST
	Nmap scan report for 220.181.38.97
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.98
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.99
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.129
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.130
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.132
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.133
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.134
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.135
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.136
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.137
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.138
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.139
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.140
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.141
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.142
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.143
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.144
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.145
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.146
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.148
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.149
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.150
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.151
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.152
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.153
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.154
	Host is up (0.17s latency).
	Nmap scan report for mx10.baidu.com (220.181.38.155)
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.156
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.157
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.158
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.159
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.160
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.161
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.162
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.163
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.164
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.165
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.166
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.167
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.168
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.170
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.171
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.172
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.173
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.174
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.175
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.176
	Host is up (0.21s latency).
	Nmap scan report for 220.181.38.177
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.178
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.179
	Host is up (0.15s latency).
	Nmap scan report for 220.181.38.180
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.181
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.182
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.183
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.184
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.185
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.186
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.187
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.188
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.189
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.190
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.191
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.192
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.193
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.194
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.195
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.196
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.197
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.198
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.199
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.200
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.201
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.202
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.203
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.204
	Host is up (0.15s latency).
	Nmap scan report for 220.181.38.205
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.206
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.207
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.208
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.209
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.210
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.211
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.213
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.214
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.215
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.216
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.217
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.218
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.219
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.220
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.221
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.222
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.223
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.224
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.225
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.226
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.227
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.228
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.229
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.230
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.231
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.232
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.233
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.234
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.235
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.236
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.237
	Host is up (0.18s latency).
	Nmap scan report for 220.181.38.238
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.239
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.240
	Host is up (0.15s latency).
	Nmap scan report for 220.181.38.241
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.242
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.243
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.244
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.245
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.246
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.247
	Host is up (0.16s latency).
	Nmap scan report for mx9.baidu.com (220.181.38.248)
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.249
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.250
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.251
	Host is up (0.16s latency).
	Nmap scan report for 220.181.38.252
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.253
	Host is up (0.17s latency).
	Nmap scan report for 220.181.38.254
	Host is up (0.16s latency).
	Nmap done: 256 IP addresses (125 hosts up) scanned in 24.79 seconds