思科路由器连接交换机的配置(思科三层交换机与路由器用什么连线)

2023-06-14 07:17:53

一、思科路由器连接交换机的配置


如上图:

ip地址设置如图再次不再写命令
waiwang路由器设置如下:

Router#sh run
Building configuration...

Current configuration : 550 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
spanning-tree mode pvst
!
!
!
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
shutdown
!
interface FastEthernet0/1
ip address 58.251.138.45 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 2.2.2.0 255.255.255.0 58.251.138.46

neiwang路由设置

Building configuration...

Current configuration : 656 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
ip dhcp pool 123
network 2.2.2.0 255.255.255.0
default-router 2.2.2.1
dns-server 2.2.2.1
!
spanning-tree mode pvst
!
interface FastEthernet0/0
ip address 2.2.2.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 58.251.138.46 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 58.251.138.0 255.255.255.0 58.251.138.45

测试结果



二、思科三层交换机与路由器用什么连线


Cisco的三层交换机有如下几种与路由器的连接方式:
1.常用方式,开启vlan子接口,配置VLAN网关,这样就能完成VLAN之间的通讯了,与路由器连接的接口配置成三层接口(可以配置IP地址)与路由器相连。去外网需要配置缺省路由(三层路由器需要配置去往外网的路由,路由器需要同时配置去往外网的缺省路由和去往内网的静态路由)-------非逻辑方式
2.古老方式:充当纯二层交换机,与路由器连接的端口配置成trunk类型,路由器与交换机连接的端口开启子接口,封装dot1q协议,配置VLAN网关地址。(三层交换机不需要配置路由,路由器配置配置去往外网的路由)---------逻辑方式
3.除了以上方式,还有另外一种方式,在思科上不是常用,不过可以通用华为等设备,三层交换机配置开启VLAN子接口,配置VLAN网关,这样就实现了VLAN间的通讯了,如果想去外网,那么与路由器的接口指定划入一个权限很大的VLAN之中,该vlan的子接口IP地址与路由器的内网IP地址同一个网段。别的VLAN想上网,那么需要借助三层交换机与路由器相连接链路的VLAN进行通讯。并且路由器需要配置去往内网的路由和外网的缺省路由。------逻辑方式
例如:
三层交换机有VLAN 10 、VLAN 20、VLAN 30.
VLAN 10属于管理员的,VLAN 20 、VLAN30属于普通用户。
三层交换机下面有两台交换机分别属于VLAN 20、VLAN30,那么VLAN网关不变,VLAN 10的子接口IP地址为
192.168.10.1/30,并且与路由器相连接的端口划入VLAN 10,路由器内网接口IP地址为192.168.10.2/30.
VLAN 20,VLAN 30想要连接外网,那么流量首先在进入从本VLAN中转发到VLAN 10中,然后VLAN 10传到路由
器的接口IP地址中。