VTP、VLAN和单臂路由配置(原创笔记)

拓扑图说明

wKioL1eNHTmhtAP0AACnqZv-Vko588.jpg-wh_50

u  SW-BVTP中的Serive modeSW-ASW-Cvtp中的client mode

u  SW-ASW-C分别划分了VLAN20VLAN30,并加入不同主机到vlan

u  PC4为管理serverSW-ASW-C配置vlan1管理的IP,可实现PC4远程管理SW-ASW-B

u  配置路由器子接口IP,实现VLAN之间的路由,达到互相访问

配置过程

通过配置VTP可以实现多以交换机vlan信息同步

1)      创建VTP模式

2)      创建接口TRUNK模式和ACESS模式

3)      创建VLAN

4)      添加到相应的VLAN

   5)     创建VLAN管理IP和网关


l SW-B上的配置:

创建VTP模式:

SW-B# conf t

SW-B (config)# vtp domain CCNA

SW- B (config)# vtp mode service

SW- B (config)# do show vtpstatus                  //查看所创建的状态(modenumber

创建接口TRUNK模式:

SW- B (config-if)#int rang f0/2-3                   //与交接机相连需要trunk模式

SW- B (config-if-rang)# switchportmode trunk 

SW-A(config-if)#int rang f0/6                       //与主机终端access模式

SW-A(config-if-rang)#sw mo ac

SW-A# show int f0/1 sw

SW-A# show int trunk                                //查看哪些端口被trunk模式

创建VLAN号:

SW- B (config)# vlan 20

SW- B (config)# vlan 30

SW- B # show vlan bri                              //查看vlan分布信息

SW- B # show vlan id 20

SW- B # show vlan name VLAN0020

创建VLAN管理IP

SW- B (config)# line vty 0 4                      //配置VTY口令

SW- B (config-line)#login

SW- B (config-line)#passwordcisco

SW- B (config)# enable secretcisco

SW- B (config)#servicepassword-encryption             //手动为所有明文密码进行加密码

SW- B (config)# int vlan 1

SW-B(config-if)# ip add192.168.100.2 255.255.255.0   //配置vlan1管理IP

SW- B (config-if)# ipdefault-gateway 192.168.100.100 //配置网关(为路由器子接口0.1

SW- B #write                                         //保存

SW- B # copy run stat                                //保存运行配置到启动配置文件中

SW- B # show run                                      //查看配置信息

 

l SW-A上的配置:

创建VTP模式:

SW-A# conf t

SW-A(config)# vtp domain CCNA

SW-A(config)# vtp mode client

SW-A(config)# do show vtpstatus                 //查看所创建的状态(modenumber

创建接口TRUNK模式:

SW-A(config)# int f0/1

SW-A(config-if)# switchport modetrunk        //与交接机相连需要trunk模式

SW-A(config-if)#int rangf0/10-11  //进入接口范围(连续),与主机终端access模式

SW-A(config-if-rang)#sw mo ac

SW-A# show int f0/1 sw

SW-A# show int trunk                         //查看哪些端口被trunk模式

同步VLAN号:(client不需要创建vlan,自动接收service同步通告消息)

SW-A# show vlan bri                       //查看vlan分布信息(来自service

SW-A# show vlan id 20

SW-A# show vlan name VLAN0020

添加接口到相应的VLAN中:

   SW-A(config)# intf0/10

   SW-A(config-if)#sw mo ac

   SW-A(config-if)#switchport access vlan 10

  SW-A(config)# int f0/11

  SW-A(config-if)# sw mo ac

  SW-A(config-if)# switchport access vlan 20

  SW-A# show int trunk

  SW-A# show vlan brief

  SW-A# show int f0/10 sw

创建VLAN管理IP

SW-A(config)# line vty 0 4                        //配置VTY口令

SW-A(config-line)#login

SW-A(config-line)#password cisco

SW-A(config)# enable secret cisco

SW-A(config)#service password-encryption   //手动为所有明文密码进行加密码

SW-A(config)# int vlan 1

SW-A(config-if)# ip add192.168.100.1 255.255.255.0          //配置vlan1管理IP

SW-A(config-if)# ipdefault-gateway 192.168.100.100 //配置网关(为路由器子接口0.1

SW-A#write                                        //保存

SW-A# copy run stat                               //保存运行配置到启动配置文件中

   SW-A# show run                                       //查看配置信息


l SW-C上的配置:

创建VTP模式:

SW-C# conf t

SW- C (config)# vtp domain CCNA

SW- C (config)# vtp mode client

SW- C (config)# do show vtpstatus               //查看所创建的状态(modenumber

创建接口TRUNK模式:

SW- C (config)# int f0/3

SW- C (config-if)# switchport modetrunk      //与交接机相连需要trunk模式

SW- C (config-if)#int rang f0/12-13  //进入接口范围(连续),与主机终端access模式

SW- C (config-if-rang)#sw mo ac

SW- C # show int f0/1 sw

SW- C # show int trunk                     //查看哪些端口被trunk模式

同步VLAN号:(client不需要创建vlan,自动接收service同步通告消息)

SW- C # show vlan bri                //查看vlan分布信息(来自service

SW- C # show vlan id 20

SW- C # show vlan name VLAN0020

添加接口到相应的VLAN中:

   SW- C (config)#int f0/10

   SW- C (config-if)#sw mo ac

   SW- C (config-if)#switchport access vlan 10

  SW- C (config)# int f0/11

  SW- C (config-if)# sw mo ac

  SW- C (config-if)# switchport access vlan 20

  SW- C # show int trunk

  SW- C # show vlan brief

  SW- C # show int f0/11 sw

创建VLAN管理IP

SW- C (config)# line vty 0 4              //配置VTY口令

SW- C (config-line)#login

SW- C (config-line)#passwordcisco

SW- C (config)# enable secretcisco

SW- C (config)#servicepassword-encryption        //手动为所有明文密码进行加密码

SW- C (config)# int vlan 1

SW- C (config-if)# ip add192.168.100.3 255.255.255.0         //配置vlan1管理IP

SW- C (config-if)# ipdefault-gateway 192.168.100.100 //配置网关(为路由器子接口0.1

SW- C #write                                         //保存

SW- C # copy run stat                               //保存运行配置到启动配置文件中

   SW- C # show run                                      //查看配置信息


l ROUTER上的配置:

2 与之相连的交换机需要配置trunk模式

2 路由器配置子接口实现不同vlan相互通信

2 配置子接口作为vlan的管理网关(交换机远程网关)vlan中主机的网关(主机访问不同vlan的网关)

首先需要对VLAN1配置子接口,作为流量转发(不带标识),且配置本征vlan需要加native参数

SW-C(config)# int f0/9

SW-C(config-if)# sw mo tr                             //配置相连交换机接口trunk模式

 

Router# conf t

Router(config)# int f0/0

Router(config-if)# no ipaddress                      //确认本接口没有IP地址(删除ip)

Router(config)# int f0/0.1                          //进入子接口0.1

Router(config-subif)# encapsulationdot1q 1 native //vlan1进行封装dot1q(既作为SW远程管理网关,也作为本地远程管理IP

Router(config-subif)# ip address192.168.100.100  255.255.255.0     //配置子接口IP(作为VLAN1管理网关)

 

Router(config)# int f0/0.10

Router(config-subif)# encapsulationdot1q 10  //vlan 10进行封装dot1q

Router(config-subif)# ip address192.168.100.10 255.255.255.0      //配置子接口IP(作为VLAN 10主机网关)

 

Router(config)# int f0/0.20

Router(config-subif)# encapsulationdot1q 20  //vlan 20进行封装dot1q

Router(config-subif)# ip address192.168.100.10 255.255.255.0        //配置子接口IP(作为VLAN 20主机网关)

 

Router# show ip route                       //查看子接口IP路由

   Router# show run

l 终端验证:

2 任何一台终端PC都可以互相通信(ping测试)

2 任何一台终端PC都可以远程登陆三台任何一个交换机进行管理