结果图:
目的:
全网互通
步骤大纲:
划分vlan隔离广播
创建IP地址池
DHCP自动分配地址
不同vlan机器互通
路由直连串口
创建路由表
配置命令:
SW1配置(原名Switch0,交换机型号为2960-24TT):
划分vlan(虚拟局域网,现实用于隔离广播,避免病毒传播,所以大纲里还会让vlan之间通信):
Switch>enable(可缩写为en) //进入特权模式
Switch#configure terminal(可缩写为conf t) //进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10 //创建vlan 10
Switch(config-vlan)#vlan 20 //创建vlan 20
Switch(config-vlan)#interface range fastEthernet0/1-11 //进入1-11范围的端口
Switch(config-if-range)#switchport access vlan 10 //将1-11的端口划分给vlan 10
Switch(config)#interface range fastEthernet0/12-23 //进入12-23范围的端口
Switch(config-if-range)#switchport access vlan 20
将24端口更改为trunk口
Switch(config)#interface fastEthernet 0/24 //进入24端口
Switch(config-if)#switchport mode trunk //改为trunk口
Switch(config)#hostname SW1(可缩写为host SW1) //更名为SW1
SW1(config)#
SW2配置(原名Switch1,交换机型号为2960-24TT):
配置同上,更名为SW2
Switch(config)#host SW2
SW2(config)#
SW3配置(原名为Multilayer Switch0,交换机型号为3560-24ps):
配置DHCP:
SW3(config)#ip dhcp pool vl10 //创建地址池,名为vl10
SW3(dhcp-config)#net 192.168.1.0 255.255.255.0 //192.168.1.0这个网络号划分给vl10地址池
SW3(dhcp-config)#default-router 192.168.1.1 //设置默认网关192.168.1.1
SW3(dhcp-config)#ip dhcp pool vl20
SW3(dhcp-config)#net 192.168.2.0 255.255.255.0
SW3(dhcp-config)#default-router 192.168.2.1
SW3(dhcp-config)#exit
配置vlan:
SW3(config)#vlan 10 //创建vlan
SW3(config-vlan)#vlan 20
SW3(config-vlan)#exit
SW3(config)#interface vlan 10 //进入vlan 10
SW3(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
SW3(config-if)#ip address 192.168.1.1 255.255.255.0 //添加IP地址
SW3(config-if)#interface vlan 20
SW3(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
SW3(config-if)#ip address 192.168.2.1 255.255.255.0
SW3(config-if)#exit
更改0/1-0/2端口为trunk
SW3(config)#interface range fastEthernet 0/1-2
SW3(config-if-range)#switchport trunk encapsulation dot1q
SW3(config-if-range)#switchport mode trunk
SW3(config-if-range)#no shut
SW3(config-if-range)#exit
SW3(config)#ip routing //开启路由功能
SW3(config)#ip dhcp excluded-address 192.168.1.1 //不将网关地址自动分配给PC机
SW3(config)#ip dhcp excluded-address 192.168.2.1
SW3(config)#
vlan互通测试:
PC0 自动获取地址成功 为192.168.1.2 网关192.168.1.1
PC1 自动获取地址成功 为192.168.2.2 网关192.168.2.1
PING测试
PC1 ping PC0
测试成功,vlan互通.
2811路由器配置:
RA(Router0)RB(Router1)都添加WIC-2T路由器
RA配置(原名Router0,路由器型号为2811)
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host RA
RA(config)#in s0/0/0 //进入s0/0/0端口
RA(config-if)#ip add 172.16.0.1 255.255.255.0
RA(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
RA(config-if)#in f0/0 //进入f0/0端口
RA(config-if)#ip add 10.0.0.2 255.255.255.0
RA(config-if)#no shut
RA(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z
RB配置(原名Router1,路由器型号2811).
Router(config)#host RB
RB(config)#in s0/0/0 //进入s0/0/0端口
RB(config-if)#ip add 172.16.0.2 255.255.255.0
RB(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
RB(config-if)#in f0/0 //进入f0/0端口
RB(config-if)#ip add 200.0.0.1 255.255.255.0
RB(config-if)#no shut
RB(config)#ip route 10.0.0.0 255.255.255.0 172.16.0.1 //添加路由表,
RB(config)#ip route 192.168.1.0 255.255.255.0 172.16.0.1
RB(config)#ip route 192.168.2.0 255.255.255.0 172.16.0.1
RB(config)#ip route 192.168.2.0 255.255.255.0 10.0.0.1
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Comments | NOTHING