如何在源代码中使用“ping 命令”?

网络工程 思科 国际会议
2021-07-23 12:21:49

我不能用 ping 'target' source 'interface'

ping 192.168.0.2 source lo0

% Invalid input detected at '^' marker.

如果我使用“ping”是可能的

R2#ping
Protocol [ip]: ip
Target IP address: 192.168.0.2
Repeat count [5]: 
Datagram size [100]: 
Timeout in seconds [2]: 
Extended commands [n]: y
Source address or interface: loopback0
Type of service [0]: 
Set DF bit in IP header? [no]: 
Validate reply data? [no]: 
Data pattern [0xABCD]: 
Loose, Strict, Record, Timestamp, Verbose[none]: 
Sweep range of sizes [n]: 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/25/59 ms

那太费时间了!我想使用“快捷命令”,但我不能!有什么建议吗?

我的拓扑,出于好奇 在此处输入图片说明

我正在尝试 ping 192.168.0.2 (R2) 源 192.168.1.1 (Loopback0)

4个回答

Packet Tracer 不提供对 IOS 的访问。它提供对 IOS 类环境的访问,该环境具有有限的 IOS 功能/命令子集,主要用于学习 CCNA 级别的概念。

因此,您在命令行上没有此选项并不令我感到惊讶。

我有同样的问题。这很奇怪,但在我的情况下,在接口上添加 ip 地址解锁了 ping 命令中的附加选项

R2#ping ip 1.1.1.1 ?
  <cr>

R2#conf t          
Enter configuration commands, one per line.  End with CNTL/Z.

R2(config)#int fa0/0
R2(config-if)#ip address 10.0.0.2 255.0.0.0
R2(config-if)#^Z

R2#ping 10.0.0.1 ?
  data      specify data pattern
  df-bit    enable do not fragment bit in IP header
  repeat    specify repeat count
  size      specify datagram size
  source    specify source address or name
  timeout   specify timeout interval
  validate  validate reply data

源地址或接口是扩展 ping 命令的部分输出。接口不能写成lo0。

查看此页面 使用扩展的 ping 和扩展的 traceroute 命令

不要提供出口接口,而是使用源 IP 地址。

ping 192.168.1.1 source 10.15.2.1 repeat 100

这应该做你想做的。