三层交换机配置

 需求

1)公司有三个部门,为确保通信安全,每个部门都处于独立的广播域

2)Vlan40为外来人员所在的Vlan,此vlan中的主机只能访问DHCP服务器

3)每个 部门的 IP地址规划为: 192.168.xx.0/24

4)每个 部门的主机均通过为 DHCP服务器获取IP地址,并且每个部门的网关IP地址为 192.168.xx.254

需求

1)所有vlan 中都使用了网关冗余技术,为了增强网关稳定性和冗余性

2)交换机之间存在很多冗余链路,必须防止环路的发生,并且能够提高链路的利用率

3)要求每个 vlan 的主机访问其他主机时,使用的都是最优的转发路径

需求

1)公司有一个出口设备 R1,连接一台外网的Web服务器

2)内网大量主机都需要访问这台外网的Web服务器

三层交换机配置_第1张图片

 配置方法:

1.交换机路由器基础配置
2.创建vlan
3.把端口加入vlan
4.设置trunk端口
5.三层交换机设置IP地址
6.配置DHCP服务器
--启动DHCP服务
--创建地址池
--设置IP地址和接口模式
--设置默认路由
7.配置DHCP中继代理
8.配置sw6
9.配置vrrp负载均衡
10.配置mstp
11.配置外网路由器

配置命令:

1)交换机路由器基础配置
sw1:
        undo terminal monitor
        system-view
        sysname sw1

sw2:
        undo terminal monitor
        system-view
        sysname sw2

sw3:
        undo terminal monitor
        system-view
        sysname sw3

sw4:
        undo terminal monitor
        system-view
        sysname sw4

sw5:
        undo terminal monitor
        system-view
        sysname sw5

sw6:
        undo terminal monitor
        system-view
        sysname sw6

DHCP:
         undo terminal monitor
        system-view
        sysname DCHP

AR1:
         undo terminal monitor
        system-view
        sysname r1

 AR2:
         undo terminal monitor
        system-view
        sysname r2
 

2)创建vlan
sw3/sw4/sw5/sw6:
vlan batch 10 20 30 40 50

sw1/sw2:        

vlan batch 10 20 30 40 50 60 70 

3)把端口加入相应的vlan中
sw3:
    int e0/0/3
    port link-type access
    port default vlan 10
sw4:
    int e0/0/3
    port link-type access
    port default vlan 20
sw5:
    int e0/0/3
    port link-type access
    port default vlan 30
sw6:
    port-group group-member e0/0/3 e0/0/4
    port link-type access
    port default vlan 40
sw1:
    int g0/0/1
    port link-type access
    port default vlan 50
    int g0/0/7
    port link-type access
    port default vlan 60
sw1:
    int g0/0/6
    port link-type access
    port default vlan 70

4)设置交换机之间的端口为trunk模式,并允许所有vlan数据通过。
sw3/sw4/sw5/sw6:
    port-group group-member e0/0/1 e0/0/2
    port link-type trunk
    port trunk allow-pass vlan all
sw1:
    port-group group-member g0/0/2 to g0/0/6
    port link-type trunk
    port trunk allow-pass vlan all
sw2:
    port-group group-member g0/0/1 to g0/0/5
    port link-type trunk
    port trunk allow-pass vlan all

5)配置sw1/sw2配置路由虚接口IP地址
sw1:
    int vlanif 10
    ip address 192.168.10.251 24
    int vlanif 20
    ip address 192.168.20.251 24
    int vlanif 30
    ip address 192.168.30.251 24
    int vlanif 40
    ip address 192.168.40.251 24
    int vlanif 50
    ip address 192.168.50.251 24
     int vlanif 60
    ip address 192.168.60.2 24 

sw2:
    int vlanif 10
    ip address 192.168.10.252 24
    int vlanif 20
    ip address 192.168.20.252 24
    int vlanif 30
    ip address 192.168.30.252 24
    int vlanif 40
    ip address 192.168.40.252 24
    int vlanif 50
    ip address 192.168.50.252 24
     int vlanif 70
    ip address 192.168.70.2 24 

6)配置DHCP服务器
dhcp:
   dhcp enable
   ip pool vlan10
   network 192.168.10.0 mask 24
   gateway-list 192.168.10.254
   ip pool vlan20
   network 192.168.20.0 mask 24
   gateway-list 192.168.20.254
   ip pool vlan30
   network 192.168.30.0 mask 24
   gateway-list 192.168.30.254
   ip pool vlan40
   network 192.168.40.0 mask 24
   gateway-list 192.168.40.254
   int g0/0/0
   ip address 192.168.50.254 24
   dhcp select global

7)配置DHCP中继代理
sw1:
   dhcp enable
   int vlanif 10
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 20
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 30
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 40
   dhcp select relay
   dhcp relay server-ip 192.168.50.254

sw2:
   dhcp enable
   int vlanif 10
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 20
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 30
   dhcp select relay
   dhcp relay server-ip 192.168.50.254
   int vlanif 40
   dhcp select relay
   dhcp relay server-ip 192.168.50.254

8)为DHCP服务器与SW1/SW2设置默认路由
dhcp:
ip route-static 192.168.10.0 24 192.168.50.251 
ip route-static 192.168.20.0 24 192.168.50.251 
ip route-static 192.168.30.0 24 192.168.50.251 
ip route-static 192.168.40.0 24 192.168.50.251    

sw1:
ip route-static 0.0.0.0 0 192.168.60.1

 sw2:
ip route-static 0.0.0.0 0 192.168.70.1

9)配置VRRP负载均衡

vrrp 10:
    主网关sw5        备份网关sw6
vrrp 20:
    主网关sw5        备份网关sw6
vrrp 30:
    主网关sw6        备份网关sw5
vrrp 40:
    主网关sw6        备份网关sw5

sw1:
int vlanif 10
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 200
int vlanif 20
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 200
int vlanif 30
vrrp vrid 30 virtual-ip 192.168.30.254
int vlanif 40
vrrp vrid 40 virtual-ip 192.168.40.254

sw2:
int vlanif 10
vrrp vrid 10 virtual-ip 192.168.10.254
int vlanif 20
vrrp vrid 20 virtual-ip 192.168.20.254
int vlanif 30
vrrp vrid 30 virtual-ip 192.168.30.254
vrrp vrid 30 priority 200
int vlanif 40
vrrp vrid 40 virtual-ip 192.168.40.254
vrrp vrid 40 priority 200

此时pc4可以获得IP地址,pc5无法获得IP地址,因为地址被占用
192.168.40.251,192.168.40.252
所以需要在DHCP服务器上排除这两个地址 

10)设置排除地址
dhcp:
reset ip pool name vlan40 all    //重置vlan40地址池
ip pool vlan40
excluded-ip-address 192.168.40.251 192.168.40.252

11 )配置多生成树
sw1/sw2/sw3/sw4/sw5/sw6:
stp mode mstp
stp region-configuration
region-name HAHA
instance 10 vlan 10
instance 20 vlan 20
instance 30 vlan 30
instance 40 vlan 40
active region-configuration
quit

12 )设置根网桥:

sw1:
stp instance 10 priority 0
stp instance 20 priority 0
stp instance 30 priority 4096
stp instance 40 priority 4096       

sw2:
stp instance 10 priority 4096
stp instance 20 priority 4096
stp instance 30 priority 0
stp instance 40 priority 0    

display stp brief 

13)配置网关路由
r1:

int g0/0/0
ip address 192.168.60.1 24
int g0/0/1
ip address 192.168.70.1 24
int g0/0/2
ip address 100.1.1.1 24
quit
ip route-static 192.168.10.0 24 192.168.60.2
ip route-static 192.168.10.0 24 192.168.70.2 preference 100
ip route-static 192.168.20.0 24 192.168.60.2
ip route-static 192.168.20.0 24 192.168.70.2 preference 100
ip route-static 192.168.30.0 24 192.168.60.2 preference 100
ip route-static 192.168.30.0 24 192.168.70.2 
ip route-static 192.168.40.0 24 192.168.60.2 preference 100
ip route-static 192.168.40.0 24 192.168.70.2 
ip route-static 200.1.1.0 24 100.1.1.2

14)配置外网路由器
r2:
int g0/0/0
ip address 100.1.1.2 24
int g0/0/1
ip address 200.1.1.254 24
quit
ip route-static 0.0.0.0 0 100.1.1.1

你可能感兴趣的:(三层交换,网络安全)