zoukankan      html  css  js  c++  java
  • 交换机配置——三层交换机实现VLAN间通信

    一、实验目的::用三层交换机让同一vlan的主机能通信,不同vlan的主机也能通信

    二、拓扑图如下

    三、具体步骤如下:、

    先给每台主机和服务器配置ip地址和网关

    例:

    (1)S1三层交换机配置:

    Switch>en  --进入特权模式
    Switch#conf t  --进入全局配置模式
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#hostname S1  --修改三层交换机主机名为S1
    S1(config)#vtp domain test  --创建vtp
    Domain name already set to test.
    S1(config)#vtp mode server  --设置当前交换机在vtp的工作模式为server
    Device mode already VTP SERVER.
    S1(config)#vlan 10  --创建vlan 10
    S1(config-vlan)#vlan 20  --创建vlan 20
    S1(config-vlan)#vlan 30  --创建vlan 30

    S1(config-vlan)#vlan 40  --创建vlan40
    S1(config-vlan)#interface f0/1  --进入端口
    S1(config-if)#switchport mode access  --将端口模式改为access模式
    S1(config-if)#switchport mode trunk  --将端口模式改为trunk模式

    S1(config-if)#interface range f0/2-3  --进入端口
    S1(config-if-range)#switchport mode access   --将端口模式改为access模式
    S1(config-if-range)#switchport access vlan 40  --将端口划入vlan 40
    S1(config-if-range)#exit   --返回上一级
    S1(config)#ip routing  --启动三层交换机的路由功能
    S1(config)#interface vlan 10  --进入vlan 10
    S1(config-if)#ip address 192.168.1.254 255.255.255.0  --给vlan 10添加ip地址
    S1(config-if)#interface vlan 20   --进入vlan 20
    S1(config-if)#ip address 192.168.2.254 255.255.255.0  --给vlan 20添加ip地址
    S1(config-if)#interface vlan 30  --进入vlan 30
    S1(config-if)#ip address 192.168.3.254 255.255.255.0  --给vlan 30添加ip地址
    S1(config-if)#interface vlan 40  --进入vlan 40
    S1(config-if)#ip address 192.168.4.254 255.255.255.0  --给vlan 40添加ip地址
    S1(config-if)#end  --返回特权模式
    S1#copy running-config startup-config  --保存配置

    [OK]  --保存成功

    (2)S2交换机配置

    Switch>en  --进入特权模式
    Switch#conf t  --进入全局配置模式
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#hostname S2  --修改交换机名为S2
    S2(config)#vtp mode client  --设置当前交换机在vtp中为客户机模式
    Device mode already VTP CLIENT.
    S2(config)#interface f0/10  --进入端口
    S2(config-if)#switchport mode trunk  --将端口设置为trunk模式

    S2(config-if)#interface f0/1  --进入端口
    S2(config-if)#switchport mode access  --将端口设置为access模式
    S2(config-if)#switchport access vlan 30  --将端口划入vlan30
    S2(config-if)#interface f0/2  --进入端口
    S2(config-if)#switchport mode access  --将端口设置为access模式
    S2(config-if)#switchport access vlan 20  --将端口划入vlan 20
    S2(config-if)#interface f0/3  --进入端口
    S2(config-if)#switchport mode access  --将端口设置为access模式
    S2(config-if)#switchport access vlan 10  --将端口划入vlan 10
    S2(config-if)#end  --返回特权模式
    S2#copy running-config startup-config  --保存配置

    [OK]  --保存成功

    (3)S3交换机配置

    Switch>en  --进入特权模式
    Switch#conf t  --进入全局配置模式
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#hostname S3  --修改交换机名为S3
    S3(config)#vtp mode client  --设置当前交换机在vtp中为客户模式
    Device mode already VTP CLIENT.
    S3(config)#interface range f0/10-12  --进入端口
    S3(config-if-range)#switchport mode trunk  --将端口设置为trunk模式

    S3(config-if-range)#interface f0/1  --进入端口
    S3(config-if)#switchport mode access  --将端口设置为access模式
    S3(config-if)#switchport access vlan 30  --将端口划入vlan 30
    S3(config-if)#interface f0/2  --进入端口
    S3(config-if)#switchport mode access   --将端口设置为access模式
    S3(config-if)#switchport access vlan 20  --将端口划入vlan20
    S3(config-if)#interface f0/3  --进入端口
    S3(config-if)#switchport mode access  --将端口设置为access模式
    S3(config-if)#switchport access vlan 10  --将端口划入vlan 20
    S3(config-if)#end  --返回特权模式
    S3#copy running-config startup-config  --保存配置

    [OK]  --保存成功

    (4)S4交换机配置

    Switch>en  --进入特权模式
    Switch#conf t  --进入全局配置模式
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#hostname S4  --修改交换机名为S4
    S4(config)#vtp mode client  --设置当前交换机在vtp中为客户模式
    Device mode already VTP CLIENT.
    S4(config)#interface f0/10  --进入端口
    S4(config-if)#switchport mode trunk  --将端口设置为trunk模式
    S4(config-if)#interface f0/1  --进入端口
    S4(config-if)#switchport mode access  --将端口设置为access模式
    S4(config-if)#switchport access vlan 30  --将端口划入vlan 30
    S4(config-if)#interface f0/2  --进入端口
    S4(config-if)#switchport mode access  --将端口设置为access模式
    S4(config-if)#switchport access vlan 20  --将端口划入vlan 20
    S4(config-if)#interface f0/3  --进入端口
    S4(config-if)#switchport mode access  --将端口设置为access模式
    S4(config-if)#switchport access vlan 10  --将端口划入vlan 10
    S4(config-if)#end  --返回特权模式
    S4#copy running-config startup-config  --保存配置

    [OK]  --保存成功

    四、验证

    测试不同vlan下的主机是否互通

    (1)PC11PC33

    vlan10vlan30互通

    (2)PC13PC21

    vlan10vlan20互通

  • 相关阅读:
    BeautifulSoup的基本用法
    打印实例
    webservice和一般处理程序
    C# 后台调用存储过程
    表格增加删除
    asp.net C# 获得配置文件AppSettings 的值
    深入浅出zookeeper(一)
    resource下的excel文件下载被损害
    csdn添加目录
    spring面试题,求求你别问我spring了!
  • 原文地址:https://www.cnblogs.com/evolve/p/9184987.html
Copyright © 2011-2022 走看看