老大给定一个网段:
192.168.55.0 / 24 , 主机地址: 256 ; 可用地址: 254
192.168.55.0000 0000 / 30---> 主机 IP 地址: 8 ; 可用地址: 6
192.168.55.0000 1000 / 29 ---> 主机 IP 地址: 8
192.168.55.0001 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0001 1000 / 29 ---> 主机 IP 地址: 8
192.168.55.0010 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0010 1000 / 29 ---> 主机 IP 地址: 8
192.168.55.0011 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0011 1000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
192.168.55.0000 0000 / 29 ---> 主机 IP 地址: 8
可用地址: 32*6 = 192
网络地址: 主机位全为 0;
表示的是一个区域, 不代表任何主机 / 设备;
广播地址: 主机位全为 1;
表示的是一个区域中的所有主机 / 设备;
注意:
以后在进行描述配置 IP 地址时, 必须将其与子网掩码一起使用
子网划分越多, 有可能会产生更多的地址浪费;
给定的网段地址: 192.168.55.0/24
如果将子网掩码变化为 30 ,
那么会产生多少个子网?
每个子网有多少个主机 IP 地址?
每个子网有多少个可用的主机地址?
写出前 5 个网段的网络地址和广播地址;
64 个子网;
4
2
网段 1192.168.55.0/30 ; 192.168.55.3/30
网段 2192.168.55.4/30 ; 192.168.55.7/30
子网掩码:
- 作用: 区分 IP 地址中的网络位和主机位;
- 结构: 左边永远是 1, 右边永远 0; 并且永远不会交叉出现;
255.255.64.0
11111111.11111111.01000000.00000000 -> wildcard bits (通配符)
-------------------------------------------------------------
IP: 网络位 + 主机位;
主机位 - N ,
---> 主机数量有 2 的 N 次方;
X:0123456789 10 的 1 次方 =
XX:00 10 11 19 99 10 的 2 次方 = 10*10
XXX: 10 的 3 次方 = 10*10*10
Y:0,1 2 的 1 次方 =
YY:00 , 01 , 10 ,11 2 的 2 次方 =
YYY: 2 的 3 次方 =
192.168.100.0/24 --> 256 , 254 可用;
2=====> 部门: 3, 表示存在 3 个不同的网段;
1=====>max:50 个主机 / 每个部门
尽量减少每个网段中的 IP 地址浪费的个数;
确定 3 个网段的地址空间分别是多少;
计算思路:
1 首先关注每个网段的主机的数量, 从而确定每个网段的
主机位的个数;
2 的 N 次方 大于等于 50+2
N >=6
2 基于主机位的个数, 从而确定每个新网段的网络位的数量,
从而确定每个网段所使用的子网掩码;
M=32-N=32-6=26, 即子网掩码为: 255.255.255.192 或者 /26
3 基于新网段的子网掩码和原来的子网掩码的数量, 确定子网位
的个数, 从而确定子网的数量;
子网位的数量 = 新网的子网掩码数量 - 老网的子网掩码数量
- 26 - 24
- = 2
所以, 子网的数量为: 2 的 2 次方;
子网地址:
192.168.100.00 000000/26 =192.168.100.0/26, 网络地址
192.168.100.63/26
192.168.100.01 000000/26 =192.168.100.64/26, 网络地址
192.168.100.127/26
192.168.100.10 000000/26 =192.168.100.128/26, 网络地址
192.168.100.191/26
192.168.100.11 000000/26 =192.168.100.192/26, 网络地址
192.168.100.255/26
案例 2:
给定网段: 192.168.65.0/24
5 个部门
每个部门 22 台主机
尽量减少每个部门的 IP 地址浪费的数量;
确定 5 个部门使用的 IP 地址空间分别是多少?
1 新网段的主机位的数量为: 5 ;
2 新网段的网络位的数量为: 27;
255.255.255.224
3 子网位是: 3 , 所以子网的数量是: 8 个;
分别列出每个子网的地址空间:
192.168.65.000 00000/27 =192.168.65.0/27, 网络地址
192.168.65.31/27, 广播地址
- 192.168.65.001 00000/27 =192.168.65.32/27
- 192.168.65.63/27
- 192.168.65.010 00000/27 =192.168.65.64/27
- 192.168.65.95/27
- 192.168.65.011 00000/27 =192.168.65.96/27
- 192.168.65.127/27
- 192.168.65.100 00000/27 =192.168.65.128/27
- 192.168.65.159/27
- 192.168.65.101 00000/27 =192.168.65.160/27
- 192.168.65.191/27
- 192.168.65.110 00000/27 =192.168.65.192/27
- 192.168.65.223/27
- 192.168.65.111 00000/27 =192.168.65.224/27
- 192.168.65.255/27
- VLSM:
virable length subnet mask - 可变长子网掩码
===================================================================
PPT 中的案例 2:
192.168.22.0/24
当将一个原始网段进行子网划分时, 如果每个子网的主机数量
不相同, 那么就先关注主机数量最多的那个子网, 先计算出来:
vlan 2 : 90 台可用主机;
2 的 n 次方 大于等于 90+2 ;
所以 n >= 7, 所以最终 N 为 7 ;
所以, 新网段的网络位的个数为 : 25 个;
故, 子网掩码为: 255.255.255.128
那么, 子网的数量为 2 个, 分别是:
子网 1: 192.168.22.0/25
子网 2: 192.168.22.128/25
所以, 我们可以将子网 1, 分配给 VLAN 2 使用
那么, 接下来我们应该继续对子网 2 进行子网划分, 应该满足 VLAN 1
的要求: 主机数量为 50, 那么:
2 的 n 次方 大于等于 50+2 ;
所以 n >=6, 所以最终 N 为 6 ;
所以, 新网段的网络位的个数为 : 26 个;
故, 子网掩码为: 255.255.255.192
那么, 子网的数量为 2 个, 分别是:
子网 2-1: 192.168.22.128/26
子网 2-2: 192.168.22.192/26
所以, 我们可以将子网 2-1, 分配给 VLAN 1 使用
那么, 接下来我们应该继续对子网 2-2 进行子网划分, 应该满足 VLAN3/4
的要求: 主机数量为 50, 那么:
2 的 n 次方 大于等于 15+2 ;
2 的 n 次方 大于等于 26+2 ;
所以 n >=5, 所以最终 N 为 5 ;
所以, 新网段的网络位的个数为 : 27 个;
故, 子网掩码为: 255.255.255.224
那么, 子网的数量为 2 个, 分别是:
子网 2-2-1: 192.168.22.192/27
子网 2-2-2: 192.168.22.224/27
所以, 我们可以将子网 2-2-1, 分配给 VLAN 3 使用
所以, 我们可以将子网 2-2-2, 分配给 VLAN 4 使用
VLAN2: 192.168.22.0/25 --- 网络地址;
192.168.22.1/25 -->PC2 地址
192.168.22.126/25 -->PC2 网关
192.168.22.127/25 --- 广播地址;
VLAN1: 192.168.22.128/26 --- 网络地址
192.168.22.129/26 -->PC1 地址
192.168.22.190/26 -->PC1 网关
192.168.22.191/26 --- 广播地址;
VLAN3: 192.168.22.192/27 --- 网络地址
192.168.22.193/27 -->PC3 地址
192.168.22.222/27 -->PC3 网关
192.168.22.223/27 --- 广播地址;
VLAN4: 192.168.22.224/27 --- 网络地址
192.168.22.225/27 -->PC4 地址
192.168.22.254/27 -->PC4 网关
192.168.22.255/27 --- 广播地址;
IP 地址汇总:
其实本质就是子网划分的反向过程
在确定汇总地址的过程中, 我们应该:
找到多个 IP 地址的相同位 (从左向右),
相同的位, 不变, 直接写, 表示的是汇总之后的 IP 地址的网络位
不同的位, 直接用 0 表示, 表示的是汇总之后的 IP 地址的主机位
相同的位的长度, 表示的是汇总之后的 IP 地址的子网掩码的长度;
案例:
1 案例 1:C 类地址划分
1.1 问题
C 类地址 192.168.55.0/24 分别使用子网掩码 / 29 和 / 30 进行划分, 划分后的子网和主机范围分别是什么?
1.2 步骤
实现此案例需要按照如下步骤进行
步骤一: C 类地址 192.168.55.0/24 使用子网掩码 / 29 进行划分
步骤二: C 类地址 192.168.55.0/24 使用子网掩码 / 30 进行划分
2 案例 2: 子网划分与 VLAN 配置
2.1 问题
公司网段 192.168.22.0/24, 生产部 VLAN1 有主机 50 台, 销售部 VLAN2 有 90 台,
财务部 VLAN3 有 15 台, 客服部 VLAN4 有 26 台, 要求划分子网实现网络互通
2.2 方案
使用 eNSP 搭建实验环境, 如图 - 1 所示
2.3 步骤
实现此案例需要按照如下步骤进行
步骤一: 子网划分
子网划分结果如图 - 2 所示:
步骤二: VLAN 配置
- [SW3]dis cu
- #
- sysname SW3
- #
- vlan batch 2 to 4
- #
- cluster enable
- ntdp enable
- ndp enable
- #
- drop illegal-mac alarm
- #
- diffserv domain default
- #
- drop-profile default
- #
- aaa
- authentication-scheme default
- authorization-scheme default
- accounting-scheme default
- domain default
- domain default_admin
- local-user admin password simple admin
- local-user admin service-type http
- #
- interface Vlanif1
- ip address 192.168.22.190 255.255.255.192
- #
- interface Vlanif2
- ip address 192.168.22.126 255.255.255.128
- #
- interface Vlanif3
- ip address 192.168.22.222 255.255.255.224
- #
- interface Vlanif4
- ip address 192.168.22.254 255.255.255.224
- #
- interface MEth0/0/1
- #
- interface GigabitEthernet0/0/1
- port link-type trunk
- port trunk allow-pass vlan 2 to 4094
- #
- interface GigabitEthernet0/0/2
- port link-type trunk
- port trunk allow-pass vlan 2 to 4094
- #
- interface GigabitEthernet0/0/3
- #
- interface GigabitEthernet0/0/4
- #
- interface GigabitEthernet0/0/5
- #
- interface GigabitEthernet0/0/6
- #
- interface GigabitEthernet0/0/7
- #
- interface GigabitEthernet0/0/8
- #
- interface GigabitEthernet0/0/9
- #
- interface GigabitEthernet0/0/10
- #
- interface GigabitEthernet0/0/11
- #
- interface GigabitEthernet0/0/12
- #
- interface GigabitEthernet0/0/13
- #
- interface GigabitEthernet0/0/14
- #
- interface GigabitEthernet0/0/15
- #
- interface GigabitEthernet0/0/16
- #
- interface GigabitEthernet0/0/17
- #
- interface GigabitEthernet0/0/18
- #
- interface GigabitEthernet0/0/19
- #
- interface GigabitEthernet0/0/20
- #
- interface GigabitEthernet0/0/21
- #
- interface GigabitEthernet0/0/22
- #
- interface GigabitEthernet0/0/23
- #
- interface GigabitEthernet0/0/24
- #
- interface NULL0
- #
- user-interface con 0
- user-interface vty 0 4
- #
- return
- [SW1]dis cu
- #
- sysname SW1
- #
- vlan batch 2 to 4
- #
- cluster enable
- ntdp enable
- ndp enable
- #
- drop illegal-mac alarm
- #
- diffserv domain default
- #
- drop-profile default
- #
- aaa
- authentication-scheme default
- authorization-scheme default
- accounting-scheme default
- domain default
- domain default_admin
- local-user admin password simple admin
- local-user admin service-type http
- #
- interface Vlanif1
- #
- interface MEth0/0/1
- #
- interface Ethernet0/0/1
- port link-type access
- #
- interface Ethernet0/0/2
- port link-type access
- port default vlan 2
- #
- interface Ethernet0/0/3
- #
- interface Ethernet0/0/4
- #
- interface Ethernet0/0/5
- #
- interface Ethernet0/0/6
- #
- interface Ethernet0/0/7
- #
- interface Ethernet0/0/8
- #
- interface Ethernet0/0/9
- #
- interface Ethernet0/0/10
- #
- interface Ethernet0/0/11
- #
- interface Ethernet0/0/12
- #
- interface Ethernet0/0/13
- #
- interface Ethernet0/0/14
- #
- interface Ethernet0/0/15
- #
- interface Ethernet0/0/16
- #
- interface Ethernet0/0/17
- #
- interface Ethernet0/0/18
- #
- interface Ethernet0/0/19
- #
- interface Ethernet0/0/20
- #
- interface Ethernet0/0/21
- #
- interface Ethernet0/0/22
- #
- interface GigabitEthernet0/0/1
- port link-type trunk
- port trunk allow-pass vlan 2 to 4094
- #
- interface GigabitEthernet0/0/2
- #
- interface NULL0
- #
- user-interface con 0
- user-interface vty 0 4
- #
- return
- [SW2]dis cu
- #
- sysname SW2
- #
- vlan batch 2 to 4
- #
- cluster enable
- ntdp enable
- ndp enable
- #
- drop illegal-mac alarm
- #
- diffserv domain default
- #
- drop-profile default
- #
- aaa
- authentication-scheme default
- authorization-scheme default
- accounting-scheme default
- domain default
- domain default_admin
- local-user admin password simple admin
- local-user admin service-type http
- #
- interface Vlanif1
- #
- interface MEth0/0/1
- #
- interface Ethernet0/0/1
- port link-type access
- port default vlan 3
- #
- interface Ethernet0/0/2
- port link-type access
- port default vlan 4
- #
- interface Ethernet0/0/3
- #
- interface Ethernet0/0/4
- #
- interface Ethernet0/0/5
- #
- interface Ethernet0/0/6
- #
- interface Ethernet0/0/7
- #
- interface Ethernet0/0/8
- #
- interface Ethernet0/0/9
- #
- interface Ethernet0/0/10
- #
- interface Ethernet0/0/11
- #
- interface Ethernet0/0/12
- #
- interface Ethernet0/0/13
- #
- interface Ethernet0/0/14
- #
- interface Ethernet0/0/15
- #
- interface Ethernet0/0/16
- #
- interface Ethernet0/0/17
- #
- interface Ethernet0/0/18
- #
- interface Ethernet0/0/19
- #
- interface Ethernet0/0/20
- #
- interface Ethernet0/0/21
- #
- interface Ethernet0/0/22
- #
- interface GigabitEthernet0/0/1
- port link-type trunk
- port trunk allow-pass vlan 2 to 4094
- #
- interface GigabitEthernet0/0/2
- #
- interface NULL0
- #
- user-interface con 0
- user-interface vty 0 4
- #
- return
VLAN 1 主机配置如图 - 3 所示:
VLAN 2 主机配置如图 - 4 所示:
VLAN 3 主机配置如图 - 5 所示:
VLAN 4 主机配置如图 - 6 所示:
验证四台主机均可以互相 ping 通
3 案例 3:IP 地址汇总
3.1 问题
将下面 IP 地址段汇总成为一个地址段, 要求汇总地址恰好包含所有地址, 即要求汇总地址段子网掩码最长
- )10.16.5.0/2410.16.7.0/2410.16.8.0/24
- )192.168.5.8/29192.168.5.16/28
3.2 步骤
实现此案例需要按照如下步骤进行
- )10.16.0.0/20
- )192.168.0.0/27
来源: http://www.bubuko.com/infodetail-2511887.html