关于单臂路由器及其扩展的学习记录
入门网络互联技术,单臂路由器在网络互联技术里面是必学和重要的一部分,难度不大,但是需要主要的小细节挺多,在这里我就将我的学习过程记录下来,分享其中的所学所获
实验介绍:
实验设备:路由器一台,交换机两台,PC端四个,服务器一台
实验要求: 1、
实验拓扑 :
实验代码:
路由器(R1):
1、激活端口,并建立DHCP
R1(config)#int f0/0
R1(config-if)#no shutdown
R1(config)#ip dhcp pool 1
R1(dhcp-config)#network 192.168.1.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.1.254
R1(dhcp-config)#dns-server 5.5.5.5
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.1.254
R1(config)#ip dhcp pool 2
R1(dhcp-config)#network 192.168.2.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.2.254
R1(dhcp-config)#dns-server 6.6.6.6
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.2.254
R1(config)#ip dhcp pool 3
R1(dhcp-config)#network 192.168.3.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.3.254
R1(dhcp-config)#dns-server 7.7.7.7
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.3.254
R1(config)#ip dhcp pool 4
R1(dhcp-config)#network 192.168.4.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.4.254
R1(dhcp-config)#dns-server 8.8.8.8
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.4.254
2、进入路由器的子接口,并封装和配置IP
R1(config)#int f0/0.1
R1(config-subif)#encapsulation dot1Q 10 //封装这种数据
R1(config-subif)#ip add 192.168.1.254 255.255.255.0
R1(config-subif)#no shut
R1(config)#int f0/0.2
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip add 192.168.2.254 255.255.255.0
R1(config-subif)#n shut
R1(config)#int f0/0.3
R1(config-subif)#encapsulation dot1Q 30
R1(config-subif)#ip add 192.168.3.254 255.255.255.0
R1(config-subif)#no shut
R1(config)#int f0/0.4
R1(config-subif)#encapsulation dot1Q 40
R1(config-subif)#ip add 192.168.4.254 255.255.255.0
R1(config-subif)#no shut
二层交换机(SW1,SW2)
1、SW1:VLAN的划分并分配接口
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#vlan 40
Switch(config-vlan)#vlan 30
Switch(config-vlan)#exit
SW1(config)#int f0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW1(config)#int f0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 20
2、SW1:接口改为中继
SW1(config)#int f0/4 (0/4口中继是为了SW2的读取)
SW1(config-if)#switchport mode trunk
SW1(config)#int f0/1 (0/1口中继是为了读取路由)
SW1(config-if)#switchport mode trunk
3、SW2:VLAN的划分及接口的分配
SW2(config)#vlan 30
SW2(config-vlan)#vlan 40
SW2(config)#int f0/4
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 40
SW2(config)#int rang f0/3,f0/2
SW2(config-if-range)#switchport mode access
SW2(config-if-range)#switchport access vlan 30
4、SW2:接口的中继
SW2(config)#int f0/1
SW2(config-if)#switchport mode trunk
实验效果:
注解:
1、R1(config-subif)#encapsulation dot1Q 20 在路由中封装子接口时,命名的“20”必须和vlan号相同。
例如:dot1Q 20对应vlan 20,vlan 20获取得DHCP也是你在子接口中配的那个dhcp pool
2、SW1作为第一个中继的交换机,需要含有所有的vlan。
例如:R1路由中有10个子接口且封装了vlan,那么SW1也需要有10个,SW2就不需要。