【ENSP】同网段不同vlan如何ping通的问题

问题:PC-10和PC-30是不同网段下,同一VLAN里的两台PC,现在想将其ping通


1. 两个PC都不设置网关

PC-10-1

  • ip:192.168.10.11
  • 子网:255.255.255.0
  • 网关:.0.0.0.0

PC-30-1

  • ip:192.168.30.13
  • 子网:255.255.255.0
  • 网关:.0.0.0.0

ping失败

# 使用PC-10-1 ping PC-30-3
PC>ping 192.168.30.13

Ping 192.168.30.13: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: Destination host unreachable

# ------------------------------------------------------------------------
# 使用PC-30-3 ping PC-10-1
PC>ping 192.168.10.11

Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.30.13: Destination host unreachable

2. 将PC-10的网关设置为PC-30的ip

PC-10-1

  • ip:192.168.10.11
  • 子网:255.255.255.0
  • 网关:192.168.30.13

PC-30-1

  • ip:192.168.30.13
  • 子网:255.255.255.0
  • 网关:.0.0.0.0
# 使用PC-10-1 ping PC-30-3
PC>ping 192.168.30.13

Ping 192.168.30.13: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!

--- 192.168.30.13 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss
  
# ------------------------------------------------------------------------
# 使用PC-30-3 ping PC-10-1
PC>ping 192.168.10.11

Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.30.13: Destination host unreachable

3. 将PC-10的网关设置为自己的ip

PC-10-1

  • ip:192.168.10.11
  • 子网:255.255.255.0
  • 网关:192.168.10.11

PC-30-1

  • ip:192.168.30.13
  • 子网:255.255.255.0
  • 网关:.0.0.0.0
# 使用PC-10-1 ping PC-30-3
PC>ping 192.168.30.13

Ping 192.168.30.13: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable

--- 192.168.10.11 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss
  
# ------------------------------------------------------------------------
# 使用PC-30-3 ping PC-10-1
PC>ping 192.168.10.11

Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.30.13: Destination host unreachable

4. 将PC-10和PC-30的网关设置为自己的ip

PC-10-1

  • ip:192.168.10.11
  • 子网:255.255.255.0
  • 网关:192.168.10.11

PC-30-1

  • ip:192.168.30.13
  • 子网:255.255.255.0
  • 网关:.192.168.30.13
# 使用PC-10-1 ping PC-30-3
PC>ping 192.168.30.13

Ping 192.168.30.13: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable
From 192.168.10.11: Destination host unreachable

--- 192.168.10.11 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss
  
# ------------------------------------------------------------------------
# 使用PC-30-3 ping PC-10-1
PC>ping 192.168.10.11

Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.30.13: Destination host unreachable
From 192.168.30.13: Destination host unreachable
From 192.168.30.13: Destination host unreachable
From 192.168.30.13: Destination host unreachable
From 192.168.30.13: Destination host unreachable

--- 192.168.30.13 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss

5. 将PC-10和PC-30的网关设置为对方的ip

PC-10-1

  • ip:192.168.10.11
  • 子网:255.255.255.0
  • 网关:192.168.30.13

PC-30-1

  • ip:192.168.30.13
  • 子网:255.255.255.0
  • 网关:192.168.10.11
# 使用PC-10-1 ping PC-30-3
PC>ping 192.168.30.13

Ping 192.168.30.13: 32 data bytes, Press Ctrl_C to break
From 192.168.30.13: bytes=32 seq=1 ttl=128 time=31 ms
From 192.168.30.13: bytes=32 seq=2 ttl=128 time=47 ms
From 192.168.30.13: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.30.13: bytes=32 seq=4 ttl=128 time=63 ms
From 192.168.30.13: bytes=32 seq=5 ttl=128 time=47 ms

--- 192.168.30.13 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/47/63 ms

# ------------------------------------------------------------------------
# 使用PC-30-3 ping PC-10-1
PC>ping 192.168.10.11

Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break
From 192.168.10.11: bytes=32 seq=1 ttl=128 time=31 ms
From 192.168.10.11: bytes=32 seq=2 ttl=128 time=47 ms
From 192.168.10.11: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.10.11: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.10.11: bytes=32 seq=5 ttl=128 time=47 ms

--- 192.168.10.11 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/43/62 ms

总结

不同网段下处于同一VLAN里的主机之间想要ping通,将自己的网关设置为对方的ip即可

上一篇:交换机高级特性简介


下一篇:交 换 技 术