【网络】CCNA实验一:Vlan、Trunk

要求:

1:不同楼层物理隔离,但逻辑相连

2:相同楼层物理相连,但逻辑隔离

3:主机可以动态获取IP地址

4:不同VLAN间可以进行通信

5:主机最终访问www.esafenet.com弹出"Test By Peterpan"字样

配置sw1:

VLAN:

sw1(config)#vlan 10

sw1(config-vlan)#name HR

sw1(config)#vlan 20

sw1(config-vlan)#name KF

VTP:

sw1(config)#vtp domain esafenet

sw1(config)#vtp mode server

Trunk:

sw1(config)#int f0/1

sw1(config-if)#switchport trunk encapsulation dot1q

sw1(config-if)#switchport mode trunk

sw1(config)#int f0/2

sw1(config-if)#switchport trunk encapsulation dot1q

sw1(config-if)#switchport mode trunk

sw1(config)#int f0/3

sw1(config-if)#switchport trunk encapsulation dot1q

sw1(config-if)#switchport mode trunk

Access:

sw1(config)#int f0/4

sw1(config-if)#switchport mode access  

sw1(config-if)#switchport access vlan 10

sw1(config)#int f0/5

sw1(config-if)#switchport mode access  

sw1(config-if)#switchport access vlan 20

配置sw2:

VTP:

sw2(config)#vtp domain esafenet

sw2(config)#vtp mode client

vlan和trunk(直接简写了):

sw2(config)#int f0/1

sw2(config-if)#sw tr en do

sw2(config-if)#sw mo tr

sw2(config-if)#int f0/2

sw2(config-if)#sw mo ac

sw2(config-if)#sw ac vl 10

sw2(config-if)#int f0/3

sw2(config-if)#sw mo ac

sw2(config-if)#sw ac vl 20

配置sw3:

VTP:

sw3(config)#vtp domain esafenet

sw3(config)#vtp mode client

vlan和trunk(直接简写了):

sw3(config)#int f0/1

sw3(config-if)#sw tr en do

sw3(config-if)#sw mo tr

sw3(config-if)#int f0/2

sw3(config-if)#sw mo ac

sw3(config-if)#sw ac vl 10

sw3(config-if)#int f0/3

sw3(config-if)#sw mo ac

sw3(config-if)#sw ac vl 20

配置r1:

r1(config)#ip dhcp pool HR
r1(dhcp-config)#network 192.168.1.0 255.255.255.0
r1(dhcp-config)#default-r1 192.168.1.254
r1(dhcp-config)#dns-server 10.1.1.1
r1(config)#ip dh pool KF
r1(dhcp-config)#network 192.168.2.0 255.255.255.0
r1(dhcp-config)#default-r1 192.168.2.254
r1(dhcp-config)#dns-server 10.1.1.1
虚拟子接口(实现vlan间通信):
r1(config)#int g0/0.1
r1(config-subif)#encapsulation dot1Q 10
r1(config-subif)#ip address 192.168.1.254 255.255.255.0
r1(config)#int g0/0.2
r1(config-subif)#encapsulation dot1Q 20
r1(config-subif)#ip address 192.168.2.254 255.255.255.0
打开接口:
r1(config)#int g0/0
r1(config-if)#no shutdown

加一条默认路由:

r1(config)#ip route 0.0.0.0 0.0.0.0 172.16.12.2

 配置r2:

 加一条默认路由:

r2(config)#ip route 0.0.0.0 0.0.0.0 172.16.12.1

简单配置下web和dns服务器:

测试结果:

原文地址:https://www.cnblogs.com/peterpan0707007/p/7827599.html