项目介绍:
某公司因公司发展需要,想把现有的网络扩建并提高其可靠性。现公司拥有财务部、销售部、生产部、技术部。它们分别在以下vlan中:财务部(vlan2)、销售部(vlan3)、生产部(vlan4)、技术部(vlan5)。它们的ip地址全部动态获取,能互相访问并可以实现外网访问,现有网路拓扑图如下:
规划:
原网络图线路单一、可靠性低;为了提高网络的可靠性跟安全性,在添加一台三层交换机,这样如果三层交换机1损坏2还可以保障网络的运行。
添加一台路由器,这样也防止路由1出现故障时网络瘫痪对公司造成影响。
方案:
STP:添加三层交换机2,把它跟三层交换机连接跟所有交换机连接成一个环形网络,这样容易产生广播风暴,为了防止它的产生我们设置STP生成树协议。
NAT:因为本公司需要连接外网的需求,所以我们设置网络地址的转换来实现对外网的访问。
HSRP:为了网络的可靠性,我们设置热备份路由选择协议,来时时监控活跃路由,当天损坏时能及时补上,不影响公司网路的运行。
Vlan:为了以后的故障排查每个vlan根据所管理的网络部门而命名。
密码:为了防止公司高手修改配置,我们给每个路由,交换机设置密码。
DHCP:ip地址全部动态获取这样可以有效节约人力。
实验拓扑图及端口号对接口详情表:
端口连接说明:
交换机表:
设备名称 |
端口号 |
对应ip |
默认网关 |
对端口号 |
SW1 |
F0/1 |
n/a |
n/a |
PC1 |
F0/2 |
n/a |
n/a |
PC2 |
|
F0/3 |
n/a |
n/a |
MS1 0/1 |
|
F0/4 |
n/a |
n/a |
MS2 0/1 |
|
SW2 |
F0/1 |
n/a |
n/a |
PC1 |
F0/2 |
n/a |
n/a |
PC2 |
|
F0/3 |
n/a |
n/a |
MS1 0/2 |
|
F0/4 |
n/a |
n/a |
MS2 0/2 |
|
SW3 |
F0/1 |
n/a |
n/a |
PC1 |
F0/2 |
n/a |
n/a |
PC2 |
|
F0/3 |
n/a |
n/a |
MS1 0/3 |
|
F0/4 |
n/a |
n/a |
MS2 0/3 |
|
SW4 |
F0/1 |
n/a |
n/a |
服务器 |
F0/2 |
n/a |
n/a |
服务器 |
|
F0/3 |
n/a |
n/a |
MS1 0/4 |
|
F0/4 |
n/a |
n/a |
MS2 0/4 |
三层交换表:
设备名称 |
端口号 |
对应ip |
默认网关 |
对端口号 |
MS1 |
F0/1 |
n/a |
n/a |
SW1 0/3 |
F0/2 |
n/a |
n/a |
Sw2 0/3 |
|
F0/3 |
n/a |
n/a |
SW3 0/3 |
|
F0/4 |
n/a |
n/a |
SW4 0/3 |
|
F0/5 |
n/a |
n/a |
MS2 0/5 |
|
F0/6 |
n/a |
n/a |
MS2 0/6 |
|
F0/7 |
192.168.5.1/24 |
255.255.255.0 |
R1 0/0 |
|
F0/8 |
192.168.7.1/24 |
255.255.255.0 |
R2 0/1 |
|
Vlan2 |
192.168.1.252 |
255.255.255.0 |
n/a |
|
Vlan3 |
192.168.2.252 |
255.255.255.0 |
n/a |
|
Vlan4 |
192.168.3.252 |
255.255.255.0 |
n/a |
|
Vlan5 |
192.168.4.252 |
255.255.255.0 |
n/a |
|
MS2 |
F0/1 |
n/a |
n/a |
SW1 0/4 |
F0/2 |
n/a |
n/a |
SW2 0/4 |
|
F0/3 |
n/a |
n/a |
SW3 0/4 |
|
F0/4 |
n/a |
n/a |
SW4 0/4 |
|
F0/5 |
n/a |
n/a |
MS1 0/5 |
|
F0/6 |
n/a |
n/a |
MS1 0/6 |
|
F0/7 |
192.168.6.1/24 |
255.255.255.0 |
R1 0/1 |
|
F0/8 |
192.168.8.1/24 |
255.255.255.0 |
R2 0/0 |
|
Vlan2 |
192.168.1.253 |
255.255.255.0 |
n/a |
|
Vlan3 |
192.168.2.253 |
255.255.255.0 |
n/a |
|
Vlan4 |
192.168.3.253 |
255.255.255.0 |
n/a |
|
Vlan5 |
192.168.4.253 |
255.255.255.0 |
n/a |
路由器表、PC表:
设备名称 |
端口号 |
对应ip |
默认网关 |
对端口号 |
R1 |
G0/0 |
192.168.5.2/24 |
255.255.255.0 |
MS1 0/7 |
G0/1 |
192.168.8.2/24 |
255.255.255.0 |
MS2 0/8 |
|
G1/0 |
100.1.1.1/24 |
255.255.255.0 |
Internet |
|
R2 |
G0/0 |
192.168.6.2/24 |
255.255.255.0 |
MS2 0/7 |
G0/1 |
192.168.7.2/24 |
255.255.255.0 |
MS1 0/8 |
|
G1/0 |
100.1.1.2/24 |
255.255.255.0 |
Internet |
|
PC1 |
NIC |
DHCP |
DHCP |
SW1 0/1 |
PC2 |
NIC |
DHCP |
DHCP |
SW1 0/1 |
PC3 |
NIC |
DHCP |
DHCP |
SW3 0/1 |
PC4 |
NIC |
DHCP |
DHCP |
SW3 0/1 |
WEB服务器 |
NIC |
192.168.4.1/24 |
255.255.255.0 |
SW4 0/1 |
MAIL服务器 |
NIC |
192.168.4.4/24 |
192.168.10.254 |
SW4 0/2 |
Internet |
F0/1 |
n/a |
n/a |
R1 1/0 |
F0/2 |
n/a |
n/a |
R2 1/0 |
|
Vlan1 |
100.1.1.3/24 |
n/a |
n/a |
备注:把所有设备改成上面的名字,过于简单就不一一描述,并全部设置好秘密统一为:“123
456”
实施
一) . 先创建Vlan并给他们命名为caiwubu, xiaoshoubu ,shengchanbu, jishubu,(命名方便维修时的快速查找)
VLAN 2 added:
Name: caiwubu
2. SW2 (vlan)#vlan 3 name xiaoshoubu
VLAN 3 modified:
Name: xiaoshoubu
3. SW3(vlan)#vlan 4 name shengchanbu
VLAN 4 modified:
Name:shengchanbu
4. SW4(vlan)#vlan 5 name jishubu
VLAN 5 added:
Name: jishubu
(二).把Pc加入到每个部门的Vlan里面。(加入Vlan后方便部门间的管理)
1. SW1 (config)#interface range f0/1 - 2
SW1 (config-if-range)#switchport accessvlan 2
2. SW2(config)#interface range f0/1 -2
SW2(config-if-range)#switchport access vlan3
3. SW3(config)#interface range f0/1 - 2
SW3(config-if-range)#switchport access vlan4
4. SW4(config)#interface range f0/1 - 2
SW4(config-if-range)#switchport access vlan5
(三) .把交换机上的接口全部trunk(中继模式实现跨交换机之间Vlan的通信)
1. SW1 (config)#interface range f0/3 - 4
SW1 (config-if-range)#switchport mode trunk
Switch(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol onInterface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on InterfaceFastEthernet0/3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol onInterface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol onInterface FastEthernet0/4, changed state to up
注:所有Vlan全部trunk,方法一样就不一一列举了,后面四句诗代表成功的意思。
(四) .把两台三层交换机跟交换机的所有接口也trunk。(trunk的双方都必须trunk才能实现Vlan的同学,两方的中继模式必须一样,不然容易不同,为了安全一般用mode trunk 中继模式。三层交换机trunk要先封装在trunk。)
1. MS1 (config)#interface range f0/1 - 4
MS1 (config-if-range)#switchport trunkencapsulation dot1q
MS1 (config-if-range)#switchport mode trunk
2. MS2(config)#INterface Range F0/1 - 4
MS2(config-if-range)#switchport trunkencapsulation dot1q
MS2(config-if-range)#switchport mode trunk
(五) .把两台三层交换机之间相连的线trunk(这样做是起到一个备份的作用如果上面的线故障下面的线依然可以用。最后要不两条线捆绑起来。)
1. MS1(config)#interface range f0/5 - 6
MS1(config-if-range)#switchport trunkencapsulation dot1q
MS1(config-if-range)#switchport mode trunk
MS1(config-if-range)#channel-group 1 modeon (捆绑起来的线序是1)
2. MS2(config)#interface range f0/5 - 6
MS2(config-if-range)#switchport trunkencapsulation dot1q
MS2(config-if-range)#switchport mode trunk
MS2(config-if-range)#channel-group 1 modeon
注:相连的两端线序必须一致。
(六).在两台三层交换机里创建Vlan,并输入网关地址。(创建完Vlan时要开启三层的路由模式)
1. MS1(vlan)#vlan 2 name caiwubu
VLAN 2 added:
Name: caiwubu
MS1(vlan)#vlan 3 name xiaoshoubu
VLAN 3 added:
Name: xiaoshoubu
MS1(vlan)#vlan 4 name shengchanbu
VLAN 4 added:
Name: shengchanbu
MS1(vlan)#vlan 5 name jishubu
VLAN 5 added:
Name: jishubu
2. MS2(vlan)#vlan 2 name caiwubu
VLAN 2 added:
Name: caiwubu
MS2(vlan)#vlan 3 name xiaoshoubu
VLAN 3 added:
Name: xiaoshoubu
MS2(vlan)#vlan 4 name shengchanbu
VLAN 4 added:
Name: shengchanbu
MS2(vlan)#vlan 5 name jishubu
VLAN 5 added:
Name: jishubu
3. MS1(config)#interface vlan 2
MS1(config-if)#
%LINK-5-CHANGED: Interface Vlan2, changedstate to up
%LINEPROTO-5-UPDOWN: Line protocol onInterface Vlan2, changed state to up
MS1(config-if)#ip address 192.168.1.252255.255.255.0
MS1(config-if)#no shutdown
MS1(config)#ip routing (开启三层交换的路由功能)
注:方法相同所以就不一一列举了。后面会创建个虚拟路由器所以网关的位数Ms1用252 MS2用253 。
(七).现在产生了广播风暴所以我们设置STP协议,把MS1设成Vlan2,3 的主根,Vlan4,5的备根,把Ms2设置为Vlan4,5 的主根,Vlan2,3 的备根。
1. MS1(config)#spanning-tree vlan 2,3 rootprimary (primary 主根)
MS1(config)#spanning-tree vlan 4,5 rootsecondary (secondary 次根)
2. MS2(config)#spanning-tree vlan 4,5 rootprimary
MS2(config)#spanning-tree vlan2,3 rootsecondary
注:在每个交换机上创建除本交换机外别的Vlan以便树根之间有区分列如:
SW1(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
SW1(vlan)#vlan 4
VLAN 4 added:
Name: VLAN0004
SW1(vlan)#vla 5
VLAN 5 added:
Name: VLAN0005
(八) .设置DHCP自动获取ip地址(为了防止自动获取时MS1跟Ms2冲突我们把ip网段分开,Ms1是1-100,Ms2是101-254。Vlan5是技术部门的服务器所以就不设置成自动获取的设置成手动获取。)
1. MS1(config)#ip dhcp pool vlan2
MS1(dhcp-config)#network 192.168.1.0255.255.255.0
MS1(dhcp-config)#default-router192.168.1.252
MS1(dhcp-config)#exit
MS1(config)#ip dhcp excluded-address192.168.1.101 192.168.1.254 (排除的字段)
注:方法一样就不一一列举,Vlan5是静态获取所以就不用设置了。
(九).把三层交换机连接路由器的端口配上ip(三层交换机端口连接路由器要开启路由功能。)
1. MS1(config)#interface fastEthernet 0/7
MS1(config-if)#no switchport
MS1(config-if)#ip address 192.168.5.1255.255.255.0
MS1(config-if)#no shutdown
2. MS1(config)#interface fastEthernet 0/8
MS1(config-if)#no switchport
MS1(config-if)#ip address 192.168.7.1255.255.255.0
MS1(config-if)#no shutdown
3. MS2(config)#interface fastEthernet 0/7
MS2(config-if)#no switchport
MS2(config-if)#ip address 192.168.6.1255.255.255.0
MS2(config-if)#no shutdown
4. MS2(config)#interface fastEthernet 0/8
MS2(config-if)#no switchport
MS2(config-if)#ip address 192.168.8.1255.255.255.0
MS2(config-if)#no shutdown
(十) .把路由器上的ip全部配置上。
1. R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.5.2255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0,changed state to up
%LINEPROTO-5-UPDOWN: Line protocol onInterface FastEthernet0/0, changed state to up
(后面这句话代表激活成功)
注:方法一样就不一一列出了。
(十一) .设置交换的ip(模拟internet的交换机)
1 . Inter (config)#interface vlan 1
Inter (config-if)#ip ad
Inter (config-if)#ip address 100.1.1.3 255.255.255.0
Inter (config-if)#no shutdown
(十二) .把路由器跟互联网的接口做下默认路由设置。
R2(config)#ip route 0.0.0.00.0.0.0 f1/0
R1(config)#ip route 0.0.0.00.0.0.0 f1/0
注:因为互联网外的ip有很多,不知道目标的ip是多少所以就用通用的0.0.0.0 表示;子网掩码也是,与路由器接口的ip也不知道是多少就用端口号表示。
(十三) .设置动态路由
1. MS1(config)#router rip
MS1(config-router)#version 2
MS1(config-router)#no auto-summary
MS1(config-router)#network 192.168.1.0
MS1(config-router)#network 192.168.2.0
MS1(config-router)#network 192.168.3.0
MS1(config-router)#network 192.168.4.0
MS1(config-router)#network 192.168.5.0
MS1(config-router)#network 192.168.7.0
2. MS2(config)#router rip
MS2(config-router)#version 2
MS2(config-router)#no auto-summary
MS2(config-router)#network 192.168.1.0
MS2(config-router)#network 192.168.2.0
MS2(config-router)#network 192.168.3.0
MS2(config-router)#network 192.168.4.0
MS2(config-router)#network 192.168.6.0
MS2(config-router)#network 192.168.8.0
3. R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 192.168.6.0
R2(config-router)#network 192.168.7.0
4. R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 192.168.5.0
R1(config-router)#network 192.168.8.0
(十四) .把默认路由注入到动态路由表里。
1. R1(config)#router rip
R1(config-router)#default-informationoriginate
2. R2(config)#router rip
R2(config-router)#default-informationoriginate
(十五) .通过NAT、ACL技术让私有ip转换成外网ip实现连接访问互联网。
1.R1(config)#ip access-list standard jx
R1(config-std-nacl)#permit 192.168.1.00.0.0.255
R1(config-std-nacl)#permit 192.168.2.00.0.0.255
R1(config-std-nacl)#permit 192.168.3.00.0.0.255
R1(config-std-nacl)#permit 192.168.4.00.0.0.255
R1(config-std-nacl)#exit
R1(config)#ip nat inside source list jxinterface f1/0 overload
R1(config)#interface range fastEthernet 0/0- 1
R1(config-if-range)#ip nat inside
R1(config-if-range)#exit
R1(config)#interface fastEthernet 1/0
R1(config-if)#ip nat outside
2. R2(config)#ip access-list standard jx
R2(config-std-nacl)#permit 192.168.1.00.0.0.255
R2(config-std-nacl)#permit 192.168.2.00.0.0.255
R2(config-std-nacl)#permit 192.168.3.00.0.0.255
R2(config-std-nacl)#permit 192.168.4.00.0.0.255
R2(config-std-nacl)#exit
R2(config)#ip nat inside source list jxinterface f1/0 overload
R2(config)#interface range f0/0 - 1
R2(config-if-range)#ip nat inside
R2(config-if-range)#exit
R2(config)#interface fastEthernet 1/0
R2(config-if)#ip nat outside
(十六) .为了防止三层交换机的故障Vlan2,3无法访问外网设置下HSRP热备份选择协议。
1. MS1(config-if)#standby 2 ip192.168.1.254
MS1(config-if)#standby 2 priority 200
MS1(config-if)#standby 2 preempt
MS1(config-if)#standby 2 track f0/7
MS1(config-if)#standby 2 track f0/8
2. MS2(config-if)#standby 2 ip192.168.1.254
MS2(config-if)#standby 2 priority 195
MS2(config-if)#standby 2 preempt
MS2(config-if)#standby 2 track f0/7
MS2(config-if)#standby 2 track f0/8
(十七)检修查看的命令
MS1#show running-config (此命令可以查看所有的配置)
MS1#show ip route (查看动态路由的条目)
MS1#show standby brief (查看HSRP的配置)
MS1#show vlan (查看Vlan的配置情况)
R1#show access-lists (查看ACL的命令状态)
MS1#show spanning-tree vlan 2 (查看STP的配置,查看Vlan几就写几)
总结
通过多方面的设置,企业的网络环境的安全性得到提高,公司内部的ip是自动获取的这样部门添加电脑时也不用跑去设置ip地址直接插上网线自动获取了,大大节约了人力;双设备的运行大大提高了带宽,使速度更快,并且也提高了网络安全的运输,某个线路的损害不会影响整个网络的运行;双路由器介入外网,可以避免网络运营商的线路损坏,可以通过另一个网络运营商获取外网,让公司在办公时感觉不到任何异常。