本实验主要内容:

1.VLAN创建

2.TRUNK的配置启用

3.单臂路由的配置

 

VLAN 中继  单臂路由的配置_基本配置

​ 

ROUTER 1配置:

F0/0.1  192.168.1.1/24

F0/0.1  192.168.2.1/24

F0/0.1  192.168.3.1/24

SWITCH配置:

F0/11、F0/12 属于VLAN2 

F0/15、F0/16 属于VLAN3

端口F0/2和G1/1配置为TRUNK

PC端配置:

PC2  192.168.2.2/24    PC3  192.168.2.3 /24     VLAN 2      网关192.168.1.1

PC4 192.168.3.2 /24   PC5  192.168.3.3 /24     VLAN 3      网关192.168.2.1

PC6 192.168.1.2 /24      PC7  192.168.1.3/24      VLAN 3    网关192.168.3.1

配置完成后,各个VLAN间PC可以通信。

交换机的配置:

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#username cisco secr cisco
Switch(config)#enable secret cisco
Switch(config)#line vty 0 4
Switch(config-line)#login local
Switch(config-line)#exec-timeout 88 9
Switch(config-line)#exit
Switch(config)#line con 0
Switch(config-line)#login local
Switch(config-line)#exec-timeout 88 9
Switch(config-line)#exit                            基本配置完毕

Switch(config)#interface vlan 1              进入 VLAN 1接口模式         
Switch(config-if)#no shut               启用VLAN 1

%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

Switch(config-if)#ip address 192.168.1.11 255.255.255.0   配置VLAN 1的IP
Switch(config-if)#ip default-gateway 192.168.1.1     配置VLAN 1的默认网关
Switch(config)#vlan 2                                创建VLAN 2
Switch(config-vlan)#name nei2                  把VLAN 2 命令为nei2
Switch(config-vlan)#int vlan 2                   进入 VLAN 2接口模式

%LINK-5-CHANGED: Interface Vlan2, changed state to up
Switch(config-if)#ip address 192.168.2.11 255.255.255.0
Switch(config-if)#ip default-gateway 192.168.2.1
Switch(config)#vlan 3
Switch(config-vlan)#name nei3
Switch(config-vlan)#int vlan 3

%LINK-5-CHANGED: Interface Vlan3, changed state to up
Switch(config-if)#ip address 192.168.3.11 255.255.255.0
Switch(config-if)#ip default-gateway 192.168.3.1
Switch(config)#int f0/10                                  进入接口F0/10
Switch(config-if)#switchport mode access       接口模式配置为ACCESS
Switch(config-if)#switchport access vlan 2       把接口划分到VLAN 2
Switch(config-if)#int f0/11
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#int f0/15
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 3
Switch(config-if)#int f0/16
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exi
Switch(config)#int f0/2                         
Switch(config-if)#switchport mode trunk              接口模式配置为trunk   
 
Switch(config-if)#switchport access  vlan 1

【或者是Switch(config-if)#switchport access native vlan 2    更改本地VLAN为VLAN 2   ,并将接口划入VLAN 2】

Switch(config-if)#exi
Switch(config)#exi

%SYS-5-CONFIG_I: Configured from console by console
Switch#wr
Building configuration...
[OK]
Switch#

路由器的配置:

Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int f0/0

Router(config-if)#no ip address    去除接口上已经配置的IP信息    
Router(config-if)#exi                  
Router(config)#exi

%SYS-5-CONFIG_I: Configured from console by console
Router#show ip int brief
Interface              IP-Address      OK? Method Status                Protocol
 
FastEthernet0/0        unassigned      YES manual up                    down
 
FastEthernet0/1        172.17.11.1     YES manual up                    down
 
Vlan1                  unassigned      YES unset  administratively down down
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#int f0/0.1

%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up

子接口不用手动开启
Router(config-subif)#encapsulation dot1q  1     为子接口封装802.1q协议,承载vlan1的流量

Router(config-subif)#ip add 192.168.1.1 255.255.255.0     配置子接口IP
Router(config-subif)#exi
Router(config)#int f0/0.2

%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
Router(config-subif)#encapsulation dot1q  2
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
Router(config-subif)#exi
Router(config)#int f0/0.3

%LINK-5-CHANGED: Interface FastEthernet0/0.3, changed state to up
Router(config-subif)#ip add 192.168.3.1 255.255.255.0

% Configuring IP routing on a LAN subinterface is only allowed if that
subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q,
or ISL vLAN.

Router(config-subif)#encapsulation dot1q  3
Router(config-subif)#ip add 192.168.3.1 255.255.255.0
Router(config-subif)#exi
Router(config)#                                                              配置完成