配置三层交换机

实验拓扑:
配置三层交换机
实验目的:pc1、pc2、pc3、pc4、server-pt实现互通

实验需求:
pc1: ip地址:192.168.10.1
子网掩码:255.255.255.0
网关:192.168.10.254
pc2: ip地址:192.168.20.1
子网掩码:255.255.255.0
网关:192.168.20.254
pc3: ip地址:192.168.30.1
子网掩码:255.255.255.0
网关:192.168.30.254
pc4: ip地址:192.168.40.1
子网掩码:255.255.255.0
网关: 192.168.40.254
server-PT: ip地址:192.168.60.1
子网掩码:255.255.255.0
网关:192.168.60.254

实验步骤:
1.配置PC机
pc1
配置三层交换机

pc2配置三层交换机
pc3
配置三层交换机
pc4
配置三层交换机
serve-pt
配置三层交换机

2.配置二层交换机
操作内容:
a、sw1和sw2分别创建vlan10、vlan20和vlan30、vlan40,并将端口加入到各自对应的vlan中,与PC机相连的端口设置access模式且允许各自所在vlan通过,其余端口创建trunk模式且允许所有vlan通过
b、sw3和sw4各自创建vlan10、vlan20、vlan30、vlan40,将所有端口创建trunk链路且允许所有vlan通过

sw1:
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw1
sw1(config)#vlan 10
sw1(config-vlan)#vlan 20
sw1(config-vlan)#exit
sw1(config)#interface fa0/1
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 10
sw1(config-if)#exit
sw1(config)#interface fa0/2
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 20
sw1(config-if)#exit
sw1(config)#interface fa0/3
sw1(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed
sw1(config-if)#switchport trunk allowed vlan all
sw1(config-if)#exit
sw1(config)#interface fa0/4
sw1(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
sw1(config-if)#switchport trunk allowed vlan all
sw1(config-if)#exit
sw1(config)#interface fa0/5
sw1(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
sw1(config-if)#switchport trunk allowed vlan all
sw1(config-if)#exit
sw1(config)#exit
sw1#write

sw2:
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw2
sw2(config)#vlan 30
sw2(config-vlan)#vlan 40
sw2(config-vlan)#exit
sw2(config)#interface fa0/1
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 30
sw2(config-if)#exit
sw2(config)#interface fa0/2
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 40
sw2(config-if)#exit
sw2(config)#interface fa0/3
sw2(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed
sw2(config-if)#switchport trunk allowed vlan all
sw2(config-if)#exit
sw2(config)#interface fa0/4
sw2(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
sw2(config-if)#switchport trunk allowed vlan all
sw2(config-if)#exit
sw2(config)#interface fa0/5
sw2(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
sw2(config-if)#switchport trunk allowed vlan all
sw2(config-if)#exit
sw2(config)#exit
sw2#write

sw3:
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw3

Switch>enable
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
sw3(config)#vlan 10
sw3(config-vlan)#vlan 20
sw3(config-vlan)#vlan 30
sw3(config-vlan)#vlan 40
sw3(config-vlan)#exit
sw3(config)#interface fa0/1
sw3(config-if)#switchport mode trunk
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit
sw3(config)#int fa0/2
sw3(config-if)#switchport mode trunk
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit
sw3(config)#interface fa0/3
sw3(config-if)#switchport mode trunk
sw3(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit
sw3#write

sw4:
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw4
sw4(config)#vlan 10
sw4(config-vlan)#vlan 20
sw4(config-vlan)#vlan 30
sw4(config-vlan)#vlan 40
sw4(config-vlan)#exit
sw4(config)#interface fa0/1
sw4(config-if)#switchport mode trunk
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4(config)#int fa0/2
sw4(config-if)#switchport mode trunk
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4(config)#interface fa0/3
sw4(config-if)#switchport mode trunk
sw4(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4#write

3.配置三层交换机
操作内容:
创建vlan10、vlan20、vlan30、vlan40,创建虚拟端口并设置网关,fa0/3设置ip地址及子网掩码,开启路由功能,配置下一跳到192.168.60.0网段

Switch>en
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#vlan 30
Switch(config-vlan)#vlan 40
Switch(config-vlan)#exit
Switch(config)#int vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.10.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#int vlan 20
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.20.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#int vlan 30
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan30, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan30, changed state to up
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.30.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#int vlan 40
%LINK-5-CHANGED: Interface Vlan40, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan40, changed state to up
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.40.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface fa0/3
Switch(config-if)#no switchport
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.50.1 255.255.255.0
Switch(config-if)#exit
Switch(config)#ip route 192.168.60.0 255.255.255.0 192.168.50.2
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#write

4.配置路由器
操作内容:配置端口的IP及子网掩码,配置默认路由

Router>en
Router#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastEthernet 0/1
%Invalid interface type and number
Router(config)#interface gigabitEthernet 0/0
Router(config-if)#no shutdown
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#ip address 192.168.50.2 255.255.255.0
Router(config)#interface gigabitEthernet 0/1
Router(config-if)#no shutdown
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
Router(config-if)#ip address 192.168.60.254 255.255.255.0
Router(config-if)#exit
Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.50.1
Router(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
Router#write

验证与测试:
配置三层交换机
配置三层交换机
实验总结:
1、不同网段通信,不要忘记配置下一跳
2、三层交换机启用路由功能命令要熟记:ip routing
3、将三层交换机的二层端口改成三层端口:no switchport

转载于:https://blog.51cto.com/13557013/2058478

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值