一 拓扑图
二 知识点
● VLAN的创建和划分
● 二层接口、TRUNK口、路由口、SVI口
● 三层链路聚合
● 冗余链路,利用两条链路接入核心交换机,提高链路带宽
● 开启生成树,在冗余的基础上避免环路
● 静态路由和默认路由
● RIP
● OSPF
●路由器间采用PPP链路协议进行通信,并且采用chap方式进 行认证。
● 用动态NAT地址转换,实现一个内网地址到地址的转换
● 设置标准访问控制列表控制内网某一网段主机对服务器的访问
三 具体配置
(一)路由器相关配置
R1路由器配置要求:
配置端口的IP地址
启用OSPF,宣告内部网段
与R2相连的端口采用PPP协议进行通信,通过CHAP方式认证
动态NAT地址转换,实现一个内网地址到地址的转换
R1具体配置:
interface FastEthernet0/0
ip address 192.168.100.1 255.255.255.0 //配置IP 地址
ip nat inside //定义该接口连接内部网络
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.200.1 255.255.255.0 //配置IP 地址
ip nat inside //定义该接口连接内部网络
duplex auto
speed auto
!
interface Serial1/0
ip address 219.220.234.1 255.255.255.0
ip access-group 101 out //对流出端口的流量进行过滤
ip nat outside //定义该接口连接外部网络
clock rate 000 //DCE端,设置时钟
!
interface Serial1/1
ip address 192.168.12.2 255.255.255.0
encapsulation ppp //用PPP协议封装
ppp authentication chap //CHAP方式认证
clock rate 000 //DCE端,设置时钟
!
router ospf 100 //启用OSPF,宣告内部网段
log-adjacency-changes
network 192.168.100.0 0.0.0.255 area 0
network 192.168.200.0 0.0.0.255 area 0
!
ip nat pool l2 219.220.234.3 219.220.234.123 netmask 255.255.255.0 //定义地址池范围
ip nat inside source list 2 pool l2 //定义内部本地地址池调用转换地址池地址
access-list 2 permit 192.168.10.0 0.0.0.255
access-list 2 permit 192.168.20.0 0.0.0.255
access-list 2 permit 192.168.30.0 0.0.0.255
access-list 2 permit 192.168.40.0 0.0.0.255//定义进行转换的内网地址
静态路由实现对的访问
ip route 202.121.241.0 255.255.255.0 219.220.234.2
ip route 192.168.6.0 255.255.255.0 192.168.200.2
ip route 192.168.7.0 255.255.255.0 192.168.200.2
ip route 192.168.3.0 255.255.255.0 192.168.100.2
ip route 192.168.11.0 255.255.255.0 192.168.12.1
!
NAT:
right#show ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 219.220.234.3:1 192.168.10.10:1 202.121.241.9:1 202.121.241.9:1
icmp 219.220.234.3:2 192.168.10.10:2 202.121.241.9:2 202.121.241.9:2
icmp 219.220.234.3:3 192.168.10.10:3 202.121.241.9:3 202.121.241.9:3
icmp 219.220.234.3:4 192.168.10.10:4 202.121.241.9:4 202.121.241.9:4
icmp 219.220.234.4:1 192.168.20.20:1 202.121.241.9:1 202.121.241.9:1
icmp 219.220.234.4:2 192.168.20.20:2 202.121.241.9:2 202.121.241.9:2
icmp 219.220.234.4:3 192.168.20.20:3 202.121.241.9:3 202.121.241.9:3
icmp 219.220.234.4:4 192.168.20.20:4 202.121.241.9:4 202.121.241.9:4
icmp 219.220.234.5:1 192.168.30.30:1 202.121.241.9:1 202.121.241.9:1
icmp 219.220.234.5:2 192.168.30.30:2 202.121.241.9:2 202.121.241.9:2
icmp 219.220.234.5:3 192.168.30.30:3 202.121.241.9:3 202.121.241.9:3
icmp 219.220.234.5:4 192.168.30.30:4 202.121.241.9:4 202.121.241.9:4
icmp 219.220.234.6:1 192.168.40.40:1 202.121.241.9:1 202.121.241.9:1
icmp 219.220.234.6:2 192.168.40.40:2 202.121.241.9:2 202.121.241.9:2
icmp 219.220.234.6:3 192.168.40.40:3 202.121.241.9:3 202.121.241.9:3
icmp 219.220.234.6:4 192.168.40.40:4 202.121.241.9:4 202.121.241.9:4
R2路由器配置要求:
配置端口的IP地址
配置RIP协议
与R1相连的端口采用PPP链路协议进行通信,并且采用chap方式进行认证。
设置默认路由使内部网络连接到
具体配置:
interface FastEthernet0/0
ip address 192.168.11.1 255.255.255.0
ip nat inside
duplex auto
speed auto
!
interface Serial1/1
ip address 192.168.12.1 255.255.255.0
encapsulation ppp //用PPP协议封装
ppp authentication chap //CHAP 方式认证
!
router rip //配置RIP
version 2
network 192.168.11.0
!
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.12.2 //默认路由到外部网络
!
R3配置要求:
设置端口的IP地址
设置静态路由是内网连到
具体配置:
interface FastEthernet0/0
ip address 202.121.241.10 255.255.255.248
duplex auto
speed auto
!
interface Serial1/0
ip address 219.220.234.2 255.255.255.0
!
ip classless 设置静态路由使内网连到
ip route 192.168.100.0 255.255.255.0 219.220.234.1
ip route 192.168.200.0 255.255.255.0 219.220.234.1
ip route 192.168.11.0 255.255.255.0 219.220.234.1
ip route 192.168.12.0 255.255.255.0 219.220.234.1
!
(二)交换机的配置
(1)局域网1内的交换机的相关配置
核心交换机配置:
SW7配置要求:
将相应的端口设为路由口,并配置IP地址
将f/22-23聚合,配置聚合口的IP地址
开启OSPF,宣告相连的网段
配置默认路由连接到
两条链路与汇聚层交换机相连,提供冗余链路
具体配置:
interface FastEthernet0/1
no switchport
ip address 192.168.76.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/2
no switchport
ip address 192.168.75.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/3
no switchport
ip address 192.168.3.254 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/22
no switchport
channel-group 1 mode on//链路聚合
no ip address
duplex auto
speed auto
!
interface FastEthernet0/23
no switchport
channel-group 1 mode on//链路聚合
no ip address
duplex auto
speed auto
!
interface FastEthernet0/24
no switchport
ip address 192.168.100.2 255.255.255.0
duplex auto
speed auto
!
interface Port-channel 1//聚合口
no switchport
ip address 192.168.125.1 255.255.255.0
!
router ospf 100//配置OSPF
log-adjacency-changes
network 192.168.100.0 0.0.0.255 area 0//与R1相连的网段
network 192.168.125.0 0.0.0.255 area 0//聚合链路的网段
network 192.168.76.0 0.0.0.255 area 0//与SW6相连的网段
network 192.168.75.0 0.0.0.255 area 0//与SW5相连的网段
network 192.168.3.0 0.0.0.255 area 0//与管理端相连的网段
!
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.100.1//默认路由与相连
SW8与SW7类似,略
汇聚层交换机
SW5配置要求:
设置与核心层相连的端口的IP地址
两条链路与核心层交换机相连,提供冗余链路
配置OSPF,宣告相应的网段
设置默认路由连到
建立访问控制列表,控制vlan40的主机对web服务器的访问
开启生成树,避免环路
具体配置:
interface FastEthernet0/1
no switchport
ip address 192.168.85.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/2
no switchport
ip address 192.168.75.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan30//创建SVI,设置IP地址
ip address 192.168.30.254 255.255.255.0
!
interface Vlan40
ip address 192.168.40.254 255.255.255.0
ip access-group 10 out//对流入的流量进行控制
!
router ospf 100//配置OSPF
log-adjacency-changes
network 192.168.30.0 0.0.0.255 area 0
network 192.168.40.0 0.0.0.255 area 0
network 192.168.75.0 0.0.0.255 area 0
network 192.168.85.0 0.0.0.255 area 0
!
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.85.1 //设置默认路由到
!
Switch#show access-lists //显示访问控制列表
Standard IP access list 10
deny 0.0.40.0 192.168.6.10//禁止vlan40的主机访问web服务器
查看生成树状态:
Switch#show spanning-tree
VLAN0030
Spanning tree enabled protocol ieee
Root ID Priority 32798
Address 0060.2F22.C781
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32798 (priority 32768 sys-id-ext 30)
Address 0060.2F22.C781
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/13 Desg FWD 19 128.13 P2p
Fa0/14 Desg FWD 19 128.14 P2p
VLAN0040
Spanning tree enabled protocol ieee
Root ID Priority 32808
Address 0060.2F22.C781
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32808 (priority 32768 sys-id-ext 40)
Address 0060.2F22.C781
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/13 Desg FWD 19 128.13 P2p
Fa0/14 Desg FWD 19 128.14 P2p
SW5 与SW6配置类似,具体配置略
接入层交换机
SW1配置要求:
创建VLAN,把端口加入到VLAN
将与汇聚层相连的端口配为trunk口
开启生成树,避免环路
具体配置:
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
switchport access vlan 10
!
查看生成树状态
Switch#show spanning-tree
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778
Address 0001.9610.1D2A
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0001.9610.1D2A
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
SW2、3、4配置与SW 1 类似,具体配置略
(2) 局域网2的交换机的相关配置
三层交换机的配置要求:
配置与R2相连的端口的IP地址
创建SVI,配置IP 地址
配置RIP
设置静态路由连到
具体配置:
interface FastEthernet0/1
no switchport
ip address 192.168.11.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan50//创建SVI,配置IP地址
ip address 192.168.50.254 255.255.255.0
!
interface Vlan60
ip address 192.168.60.254 255.255.255.0
!
router rip//配置RIP
version 2
network 192.168.11.0
network 192.168.50.0
network 192.168.60.0
!
ip classless
静态路由连到
ip route 192.168.12.0 255.255.255.0 192.168.11.1
ip route 219.220.234.0 255.255.255.0 192.168.11.1
ip route 202.121.241.8 255.255.255.248 192.168.11.1
!
二层交换机相关配置
SW9配置要求:
创建VLAN,将端口划分到VLAN
将与三层交换机相连的端口配为trunk口
具体配置:
interface FastEthernet0/1
switchport access vlan 50
!
interface FastEthernet0/15
switchport mode trunk
!
SW10 与SW8类似,具体配置略
四 测试结果
局域网内不同VLAN的主机可以互通
两个局域网内的主机都可对进行访问
局域网1内的vlan40的主机不能访问WWW服务器,其他的网段都能访问