首页 > 编程 > BAT > 正文

批处理常用网络命令和符号篇

2020-06-09 14:02:43
字体:
来源:转载
供稿:网友

2.1学习 ping  ipconfig  arp  start  shutdown  taskkill 命令

学习要点:
1.测试IP连接:ping
2.查看IP配置:ipconfig
3.解析地址:arp
4.开启命令:start
5.关闭或重启计算机:shutdown
6.关闭指定进程taskkill

一.测试IP连接:ping

用来检查网络是否通畅或者网络连接速度的命令。在此,我们只了解一些基本的参数就可以了。

-n count 发送count指定的Echo数据包数。
定义向目标IP发送数据包的次数,默认为4次。通过此命令可以收集到一些信息。如数据包返回的平均时间为多少,
最快时间为多少,最慢时间为多少等等。


例1
C:/Documents and Settings/mzybar>ping -n 3 www.baidu.com

Pinging www.jb51.net [121.14.88.14] with 32 bytes of data:

Reply from 121.14.88.14: bytes=32 time=3ms TTL=57
Reply from 121.14.88.14: bytes=32 time=3ms TTL=57
Reply from 121.14.88.14: bytes=32 time=2ms TTL=57

Ping statistics for 121.14.88.14:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 3ms, Average = 2ms


我们分析一下吧:

Ping statistics for 121.14.88.14:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
从这里可以知道在给www.baidu.com发送3个数据包的过程当中,返回了3个,没有数据包丢失。

Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 3ms, Average = 2ms
这3个数据包当中返回速度最快为2ms,最慢为3ms,平均速度为2ms。


例2
ping -n 11 127.0.0.1 >nul
ping本机11次,可用于批处理延时10秒。命令中的>nul为屏蔽输出。
简短式可以写成:
ping -n 11 127.1 >nul

-w timeout 指定超时间隔,单位为毫秒。

例3
ping 1 -n 1 -w 10000 2>nul 1>nul
批处中可以用于延时10秒。

二.查看IP配置:ipconfig

由于批处理中经常对计算机的TCP/IP 配置信息的截取,这里我们只讲一下/all参数就行了。

/all参数
作用:显示所有适配器的完整 TCP/IP 配置信息。当使用IPConfig时不带任何参数选项,那么它为每个已经配置了的
接口显示IP地址、子网掩码和缺省网关值。

例1
C:/Documents and Settings/mzybar>ipconfig

Windows IP Configuration


Ethernet adapter 本地连接:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 192.168.0.73
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.0.254

这里显示的信息为:

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表