#Router0设置 Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fa0/0 Router(config-if)#ip addr 10.1.1.254 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#interface fa0/1 Router(config-if)#ip addr 20.1.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#do show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type1, N2 - OSPF NSSA external type2 E1 - OSPF external type1, E2 - OSPF external type2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.1.1.0/24 is directly connected, FastEthernet0/0 L 10.1.1.254/32 is directly connected, FastEthernet0/0 20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 20.1.1.0/24 is directly connected, FastEthernet0/1 L 20.1.1.1/32 is directly connected, FastEthernet0/1 Router(config-if)#exit Router(config)#ip route 0.0.0.0 0.0.0.0 20.1.1.2 # --------Router1配置 Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fa1/0 Router(config-if)#ip addr 50.1.1.254 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up Router(config-if)#exit Router(config)#interface fa0/0 Router(config-if)#ip addr 20.1.1.2 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#interface fa0/1 Router(config-if)#ip addr 30.1.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up Router(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#do show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type1, N2 - OSPF NSSA external type2 E1 - OSPF external type1, E2 - OSPF external type2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set 20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 20.1.1.0/24 is directly connected, FastEthernet0/0 L 20.1.1.2/32 is directly connected, FastEthernet0/0 30.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 30.1.1.0/24 is directly connected, FastEthernet0/1 L 30.1.1.1/32 is directly connected, FastEthernet0/1 50.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 50.1.1.0/24 is directly connected, FastEthernet1/0 L 50.1.1.254/32 is directly connected, FastEthernet1/0 Router(config)#ip route 10.1.1.0 255.255.255.0 20.1.1.1 Router(config)#ip route 40.1.1.0 255.255.255.0 30.1.1.2 #-------------Router2配置 Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fa0/1 Router(config-if)#ip addr 40.1.1.254 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Router(config-if)#exit Router(config)#interface fa0/0 Router(config-if)#ip addr 30.1.1.2 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#ip route 0.0.0.0 0.0.0.0 30.1.1.1
配置完成后,通过ping测试网段之间的连通
配置ACL
#Router1上配置ACL Router(config)#access-list 50 deny 10.0.0.0 0.255.255.255 Router(config)#access-list 50 deny host 40.1.1.1 Router(config)#access-list 50 permit any Router(config)#interface fa1/0 Router(config-if)#ip access-group 50 out #查看ACL配置 Router(config)#do show access-list Standard IP access list 50 10 deny 10.0.0.0 0.255.255.255 20 deny host40.1.1.1 30 permit any #Router2上配置ACL Router(config)#access-list 40 deny host 10.1.1.1 Router(config)#access-list 40 permit any Router(config)#interface fa0/1 Router(config-if)#ip access-group 40 out