您的位置:首页 > 其它

关于PC网卡和默认网关不在同网段通信的解释

2013-03-12 22:55 501 查看
最近有粉丝纠结在这个问题上。有这个想法还是有点拘泥于经验了,好像思路纠结在PC网卡和网关接口处于同一个广播域里,地址不同网段,怎么可能学到ARP表项呢?原问题:pc地址和网关不是一个网段可以通信,上层是直连的一个3层交换机,交换机是别人的也没看配置,代理arp有没有可能可以实现这个,还有假设我在路由器上开启某些功能是不是可以实现这个?其实这个问题没有想象中复杂,真实中的配置应该是这样,PC的网卡地址和网关地址不在同一个广播域中。例如这样配置,把PC的网卡地址配置成192.168.1.2,默认网关地址设置成10.1.1.1,然后将PC接入三层交换机的e0/0接口上。三层交换机的e0/1接口配置成trunk并permit所有vlan通过,e0/0接口默认属于vlan 1。此时配置int vlan 1,ip地址配置成192.168.1.1,再配置int vlan 2,ip地址配置成10.1.1.1。此时,觉得电脑可以ping通10.1.1.1吗?此时问题就是,vlan 1内的主机想要ping通vlan 2的网关地址,是否可以通?就相当于问,三层交换机能否做到vlan间路由?当然可以。靠什么技术?当然是代理ARP,PC学到10.1.1.1的ARP表的mac地址是三层交换机上vlan 1接口的mac地址,反向亦然。这个是基本的CCNA内容了吧。关于这样的网络模型,笔者在工作中还曾经遇到过相同的内容,一个局点的一台服务器设置就如此,原网络中的三层交换机为一台cisco交换机,由于板卡故障要替换一台H3C交换机上线。H3C交换机参照cisco交换机配置上线后,无法通信,为什么呢?其实原因很简单,cisco交换机接口上的代理arp是默认开启的,而H3C交换机接口上是默认关闭的,所以完全相同的配置方式是无法上线的,到相应接口上开启了一下代理ARP问题就解决了。其实遇到问题的时候,只要对协议有扎实的掌握,不怕没有思路解决。当看到网卡地址和网关地址不在同一网段能ping通的时候,如果有怀疑,第一时间是查看arp表项。如果arp表项学到了,那么根据对ARP协议的掌握,它是靠二层的广播工作,那么两个接口有可能在一个广播域下吗?当然绝无可能。既然不可能在同一个广播域下,那么就意味着跨三层了,跨三层的通信,在一台三层交换机上能否实现?当然可以,三层交换机就是专门干这个的!永远扎实地掌握协议的工作流程,一步步通过严谨地依据去排查和推断,问题总会水落石出。其实这个问题很好玩!有机会我会再发一些问题定位上来,重要的不是结果,而是思路,思路有了,协议掌握够扎实了,除非是软硬件bug,否则没什么解决不了的问题,要有这个自信,哈!有粉丝没看懂,继续补个实验环境上来,图是这样的:PC的配置是这样:
交换机的配置是这样:
Switch#sh runBuilding configuration...Current configuration : 1135 bytes!version 12.2no service timestamps log datetime msecno service timestamps debug datetime msecno service password-encryption!hostname Switch!!!!!!!!!!!!!!!!!!interface FastEthernet0/1!interface FastEthernet0/2switchport access vlan 2!interface FastEthernet0/3!interface FastEthernet0/4!interface FastEthernet0/5!interface FastEthernet0/6!interface FastEthernet0/7!interface FastEthernet0/8!interface FastEthernet0/9!interface FastEthernet0/10!interface FastEthernet0/11!interface FastEthernet0/12!interface FastEthernet0/13!interface FastEthernet0/14!interface FastEthernet0/15!interface FastEthernet0/16!interface FastEthernet0/17!interface FastEthernet0/18!interface FastEthernet0/19!interface FastEthernet0/20!interface FastEthernet0/21!interface FastEthernet0/22!interface FastEthernet0/23!interface FastEthernet0/24!interface GigabitEthernet0/1!interface GigabitEthernet0/2!interface Vlan1ip address 192.168.1.1 255.255.255.0!interface Vlan2ip address 10.1.1.1 255.255.255.0!ip classless!!!!!!!line con 0line vty 0 4login!!!end
路由器只需要把fa0/0接口no shut,目的就是为了让交换机的fa0/2口up起来。
从PC上ping 10.1.1.1:
PC>ping 10.1.1.1Pinging 10.1.1.1 with 32 bytes of data:Reply from 10.1.1.1: bytes=32 time=5ms TTL=255Reply from 10.1.1.1: bytes=32 time=2ms TTL=255Reply from 10.1.1.1: bytes=32 time=3ms TTL=255Reply from 10.1.1.1: bytes=32 time=4ms TTL=255Ping statistics for 10.1.1.1:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 2ms, Maximum = 5ms, Average = 3msPC>arp -aInternet Address      Physical Address      Type10.1.1.1              00d0.ff28.1839        dynamic192.168.1.1           00d0.ff28.1839        dynamic
代理ARP的典型现象。
原文出自:http://page.renren.com/601435534/note/856340216
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: