思智网络—旗下品牌
忘记密码
长沙云服务器,长沙服务器租用,长沙服务器托管
全国统一服务热线:88900700(7*24h)
 思智网络——专注于企业级IDC解决方案!
  • 顶级网络高速接入
  • 十年经验管理完善
  • 资质齐全放心可靠
  • 专业服务快速稳定
  • 免费备案快速高效
  • 自维机房全年无休
  • 免费测试省钱省心
  • 行业评价有口皆碑

解决方案专区 more>>

负载均衡解决方案
服务器网络安全解决方案
数据异地灾备解决方案
网络加速综合解决方案

典型客户 more>>

  • 潇湘晨报网
  • SANY
  • 盛大金禧
  • 湖南有线
  • 金杯电工
  • 长沙长海医院
  • 蝴蝶树
  • 中国人民大学
  • 湖南妈妈网
  • 美迪装饰
  • 小新星
  • 湖南武警医院
思智网络学院

长沙服务器托管中心教您子网划分与静态路由的配置

发表:湖南数据中心文员   文章来源:长沙服务器托管中心   
[摘要] 1 子网划分 1.1 问题 某企业现有100名员工,总共三个部门,其中生产部31人,销售部、40人,技术部29人,现将192.168.1.0/24网段的IP地址分配给三个部门使用,……


1 子网划分
1.1 问题
某企业现有100名员工,总共三个部门,其中生产部31人,销售部、40人,技术部29人,现将192.168.1.0/24网段的IP地址分配给三个部门使用,如何更加合理有效的将此网段分给三个部门使用呢。
1.2 方案
192.168.1.0/24分给三个部门来使用,需进行子网划分,在规划本企业IP地址时,需考虑如下两点:
1)所划分子网的个数至少要满足企业部门总个数并且还需考虑到部门的扩展,例如随着企业的发展需求又新扩展了一个业务部,不必因部门扩展而重新划分子。
2)每个子网的可用主机IP个数要大于员工总人数,为方便企业部门新员工入职的扩展。
1.3 实现
1.192.168.1.0/24划分出3个子网分给三部门使用
1)划分3个子网计算出需向主机借几位
2n>=所要划分子网的个数,本企业划分3个子网
2n>=3
计算出n=2
因此需向主机位借2位
2)计算划分子网后的子网掩码
划分前:255.255.255.0,对应二进制为11111111.11111111.11111111.00000000。
划分后:255.255.255.192,对应二进制11111111.11111111.11111111.11000000。
3)计算划分子网后的子网ID,如表-1所示
表-1 子网划分及说明
 
4)计算每个子网的可用主机IP范围及广播地址,如表-2所示
表-2 子网的可用IP范围及广播地址
 
1.4 扩展
2 配置静态路由
2.1 问题
路由器可以将不同网段之间的网络连接到一起,当路由器接收到数据包后要查看数据包中的目标IP,再检查自己的路由表,如果路由表中有和目标IP相匹配的路由条目,路由器才能将数据包按照该路由条目所指定的端口转发出去,实现不同网络之间的通信,那么路由器中的路由表是如何实现的呢?配置了路由器接口IP并为UP状态路由表中自动生成直连路由,对于非直连的路由,需通过静态路由管理员手工添加或通过配置动态路自动学习。
2.2 方案
网络环境及IP地址规划,如图-1所示。
 
图-1
本例中的配置练习采用思科模拟器 —— Cisco Packet Tracer 6.0,Route采用2621路由器实现。
2.3 实现
1.配置静态路由实现不同网络之间的能信
1)R1上配置接口IP
1.    R1(config)#interface fastEthernet 0/0
2.    R1(config-if)#ip address 192.168.1.254 255.255.255.0
3.    R1(config-if)#no shutdown
4.    R1(config-if)#exit
5.    R1(config)#interface fastEthernet 0/1
6.    R1(config-if)#ip address 192.168.2.1 255.255.255.0
7.    R1(config-if)#no shutdown
2)R2上配置接口IP
1.    R2(config)#interface fastEthernet 0/1
2.    R2(config-if)#ip address 192.168.2.2 255.255.255.0
3.    R2(config-if)#no shutdown
4.    R2config-if)#exit
5.    R2(config)#interface fastEthernet 0/0
6.    R2(config-if)#ip address 192.168.3.254 255.255.255.0
7.    R2(config-if)#no shutdown
3)R1上添加静态路由
1.    R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
4)R1上查看路由表
1.    R1#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    S    192.168.3.0/24 [1/0] via 192.168.2.2                     //S表示静态路由
5)R2上添加静态路由
1.    R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
6)R2上查看路由条目
1.    R2#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    S    192.168.1.0/24 [1/0] via 192.168.2.1                     //S表示静态路由
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    C    192.168.3.0/24 is directly connected, FastEthernet0/0
7)配置PC1的IP地址为192.168.1.1,网关为192.168.1.254
8)配置PC2的IP地址为192.168.3.1,网关为192.168.3.254
9)测试网络连通性,PC1 ping 192.168.3.1
1.    PC>ping 192.168.3.1
2.    
3.    Pinging 192.168.3.1 with 32 bytes of data:
4.    
5.    Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
6.    Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
7.    Reply from 192.168.3.1: bytes=32 time=10ms TTL=126
8.    Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
9.    
10.    Ping statistics for 192.168.3.1:
11.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
12.    Approximate round trip times in milli-seconds:
13.        Minimum = 1ms, Maximum = 11ms, Average = 8ms
2.配置浮动静态路由
1)在以上静态路由实验的基础上,先分别进入R1与R2的特权模式输入write命令保存配置信息,然后分别进入R1与R2的物理配置界面,点击开关按钮关闭路由器,添加NM-1FE-TX模块并再次点击开关按钮,如下图-2所示。
/
图-2
2)添加模块后将R1的F1/0接口连接到R2的F1/0接口修改拓扑如下图-3所示:
/
图-3
3)配置R1的F1/0接口IP
1.    R1(config)#interface fastEthernet 1/0
2.    R1(config-if)#ip address 192.168.4.1 255.255.255.0
3.    R1(config-if)#no shutdown
4)配置R2的F1/0接口IP
1.    R2(config)#interface fastEthernet 1/0
2.    R2(config-if)#ip address 192.168.4.2 255.255.255.0
3.    R2(config-if)#no shutdown
5)R1上添加静态浮动路由
1.    R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.4.2 50   //管理距离50
6)R2上添加静态浮动路由
1.    R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.4.1 50  //管理距离50
7)R1上查看路由表
1.    R1#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    S    192.168.3.0/24 [1/0] via 192.168.2.2
15.    C    192.168.4.0/24 is directly connected, FastEthernet1/0
16.    R1#show ip rou
17.    R1#show ip route
18.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
19.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
20.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
21.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
22.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
23.           * - candidate default, U - per-user static route, o - ODR
24.           P - periodic downloaded static route
25.    
26.    Gateway of last resort is not set
27.    
28.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
29.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
30.    S    192.168.3.0/24 [1/0] via 192.168.2.2  //只有下一跳为192.168.2.2的静态路由
31.    C    192.168.4.0/24 is directly connected, FastEthernet1/0
8)禁用F/01接口
1.    R1(config)#interface fastEthernet 0/1
2.    R1(config-if)#shutdown
9)R1上查看路由表
1.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
2.    S    192.168.3.0/24 [50/0] via 192.168.4.2//下一跳接口为192.168.4.2的路由生效
3.    C    192.168.4.0/24 is directly connected, FastEthernet1/0
10)测试网络连通性,PC1 ping 192.168.3.1
1.    PC>ping 192.168.3.1
2.    
3.    Pinging 192.168.3.1 with 32 bytes of data:
4.    
5.    Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
6.    Reply from 192.168.3.1: bytes=32 time=10ms TTL=126
7.    Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
8.    Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
9.    
10.    Ping statistics for 192.168.3.1:
11.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
12.    Approximate round trip times in milli-seconds:
13.        Minimum = 0ms, Maximum = 11ms, Average = 5ms
3.配置静态路由实现三个路由器之间的全网络互通
1)网络环境及IP地址规划,如图-4所示
/
图-4
2)R1上配置接口IP
1.    Router(config)#interface fastEthernet 0/0
2.    R1(config-if)#ip address 192.168.1.254 255.255.255.0
3.    R1(config-if)#no shutdown
4.    R1(config-if)#exit
5.    R1(config)#interface fastEthernet 0/1
6.    R1(config-if)#ip address 192.168.2.1 255.255.255.0
7.    R1(config-if)#no shutdown
3)R2上配置接口IP
1.    R2(config)#interface f0/1
2.    R2(config-if)#ip address 192.168.2.2 255.255.255.0
3.    R2(config-if)#no shutdown
4.    R2(config-if)#exit
5.    R2(config)#interface fastEthernet 0/0
6.    R2(config-if)#ip address 192.168.3.1 255.255.255.0
7.    R2(config-if)#no shutdown
4)R3上配置接口IP
1.    R3(config)#interface fastEthernet 0/1
2.    R3(config-if)#ip address 192.168.3.2 255.255.255.0
3.    R3(config-if)#no shutdown
4.    R3(config-if)#exit
5.    R3(config)#interface fastEthernet 0/0
6.    R3(config-if)#ip address 192.168.4.254 255.255.255.0
7.    R3(config-if)#no shutdown
5)R1、R2、R3上分别添加静态路由
1.    R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
2.    R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
3.    
4.    R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
5.    R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
6.    
7.    R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
8.    R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
6)R1上查看路由表
1.    R1#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    S    192.168.3.0/24 [1/0] via 192.168.2.2    //静态路由
15.    S    192.168.4.0/24 [1/0] via 192.168.2.2    //静态路由
7)R2上查看路由表
1.    R2#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    S    192.168.1.0/24 [1/0] via 192.168.2.1    //静态路由
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    C    192.168.3.0/24 is directly connected, FastEthernet0/0
15.    S    192.168.4.0/24 [1/0] via 192.168.3.2    //静态路由
8)R3上查看路由表
1.    R3#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is not set
11.    
12.    S    192.168.1.0/24 [1/0] via 192.168.3.1    //静态路由
13.    S    192.168.2.0/24 [1/0] via 192.168.3.1    //静态路由
14.    C    192.168.3.0/24 is directly connected, FastEthernet0/1
15.    C    192.168.4.0/24 is directly connected, FastEthernet0/0
9)按图-4配置PC的IP地址
10)测试网络连通性,PC1 ping 192.168.2.2、192.168.3.1、192.168.3.2、192.168.4.1
1.    PC>ping 192.168.2.2                            //ping 192.168.2.2
2.    
3.    Pinging 192.168.2.2 with 32 bytes of data:
4.    
5.    Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
6.    Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
7.    Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
8.    Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
9.    
10.    Ping statistics for 192.168.2.2:
11.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
12.    Approximate round trip times in milli-seconds:
13.        Minimum = 0ms, Maximum = 0ms, Average = 0ms
14.    
15.    PC>ping 192.168.3.1                          //ping 192.168.3.1
16.    
17.    Pinging 192.168.3.1 with 32 bytes of data:
18.    
19.    Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
20.    Reply from 192.168.3.1: bytes=32 time=3ms TTL=254
21.    Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
22.    Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
23.    
24.    Ping statistics for 192.168.3.1:
25.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
26.    Approximate round trip times in milli-seconds:
27.        Minimum = 0ms, Maximum = 3ms, Average = 0ms
28.    
29.    PC>ping 192.168.3.2                          //ping 192.168.3.2
30.    
31.    Pinging 192.168.3.2 with 32 bytes of data:
32.    
33.    Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
34.    Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
35.    Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
36.    Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
37.    
38.    Ping statistics for 192.168.3.2:
39.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
40.    Approximate round trip times in milli-seconds:
41.        Minimum = 0ms, Maximum = 12ms, Average = 6ms
42.    
43.    PC>ping 192.168.4.1                          //ping 192.168.4.1
44.    
45.    Pinging 192.168.4.1 with 32 bytes of data:
46.    
47.    Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
48.    Reply from 192.168.4.1: bytes=32 time=10ms TTL=125
49.    Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
50.    Reply from 192.168.4.1: bytes=32 time=22ms TTL=125
51.    
52.    Ping statistics for 192.168.4.1:
53.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
54.    Approximate round trip times in milli-seconds:
55.        Minimum = 0ms, Maximum = 22ms, Average = 8ms
4.配置静态路由及默认路由实现三个路由器之间的全网络互通
1)网络拓扑如图-4
2)R1、R3取消静态路由
1.    R1(config)#no ip route 192.168.3.0 255.255.255.0 192.168.2.2
2.    R1(config)#no ip route 192.168.4.0 255.255.255.0 192.168.2.2
3.    
4.    R3(config)#no ip route 192.168.1.0 255.255.255.0 192.168.3.1
5.    R3(config)#no ip route 192.168.2.0 255.255.255.0 192.168.3.1
3)R1、R3添加默认路由
1.    R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
2.    R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1
4)R1上查看路由表
1.    R1#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is 192.168.2.2 to network 0.0.0.0
11.    
12.    C    192.168.1.0/24 is directly connected, FastEthernet0/0
13.    C    192.168.2.0/24 is directly connected, FastEthernet0/1
14.    S*   0.0.0.0/0 [1/0] via 192.168.2.2     //默认路由
5)R3上查看路由表
1.    R3#show ip route
2.    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
3.           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
4.           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
5.           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
6.           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
7.           * - candidate default, U - per-user static route, o - ODR
8.           P - periodic downloaded static route
9.    
10.    Gateway of last resort is 192.168.3.1 to network 0.0.0.0
11.    
12.    C    192.168.3.0/24 is directly connected, FastEthernet0/1
13.    C    192.168.4.0/24 is directly connected, FastEthernet0/0
14.    S*   0.0.0.0/0 [1/0] via 192.168.3.1     //默认路由
6)测试网络连通性,PC1 ping 192.168.4.1
1.    PC>ping 192.168.4.1
2.    
3.    Pinging 192.168.4.1 with 32 bytes of data:
4.    
5.    Reply from 192.168.4.1: bytes=32 time=1ms TTL=125
6.    Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
7.    Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
8.    Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
9.    
10.    Ping statistics for 192.168.4.1:
11.        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
12.    Approximate round trip times in milli-seconds:
13.        Minimum = 0ms, Maximum = 14ms, Average = 7ms

湖南数据中心主要业务范围:湖南主机托管长沙服务器租用长沙服务器托管湖南服务器托管,知名品牌,值得信赖!

收缩

  • 售前咨询
  • 技术支持
  • 备案专员
  • 24小时客服热线:
  • 88900700

微信号:hnidccn