交换机之间用管理vlan互联,用网管机可以对其进行运维,
拓朴描述:
网关起在S2上,管理vlan999,IP:1.1.1.1/30,lookback 0 地址用2.2.2.2/32当做外网接口IP
S1上:管理vlan999,IP:1.1.1.2/30,需要PC1仅能访问2.2.2.2的地址,不能访问vlan 20 、vlan 999的网段
S1配置(接入层交换机):
sysname S1
#
vlan batch 10 20 999
#
interface Vlanif999
ip address 1.1.1.2 255.255.255.252
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/24
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
S2配置:(核心层配置)
sysname S2
#
vlan batch 10 20 999
#
interface GigabitEthernet0/0/24
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface Vlanif10
ip address 10.1.1.254 255.255.255.0
#
interface Vlanif20
ip address 10.2.2.254 255.255.255.0
#
interface Vlanif999
ip address 1.1.1.1 255.255.255.252
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
acl number 3001
rule 5 permit ip source 10.2.2.0 0.0.0.255
rule 10 deny ip source 10.1.1.0 0.0.0.255 destination 10.2.2.0 0.0.0.255
rule 15 deny ip source 10.1.1.0 0.0.0.255 destination 1.1.1.0 0.0.0.252
#
interface GigabitEthernet0/0/24
port link-type trunk
port trunk allow-pass vlan all
traffic-filter inbound acl 3001
#
我们配好后,发现PC2 ping不通1.1.1.2,就是S1的管理地址,那么问题在哪里呢?PC2先到S1的网关254,网关发现目的地址和自己不同段,于是按路由表扔到了vlan999段,然后vlan999查了下mac表,没找到1.1.1.2,于是通过trunk发给了S1。但问题来了,我们列出S1的路由表,发现只有本机地址和环回地址,就是S1收到了地址,但不知道从哪里回包,我们写一条默认路由,匹配到管理网段999的地址上,就实现了PC对S1的访问:
ip route-static 0.0.0.0 0 1.1.1.1