Cyber_Security_Notes/B. 第二阶段/拓扑练习/0829_子网划分.md
2024-08-29 14:55:35 +08:00

151 lines
4.6 KiB
Markdown

# 子网划分
![image-20240829103825275](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240829103825275.png)
### 一、VLAN
- **SW2**
```
[SW2]vlan batch 10 20
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 10
[SW2-GigabitEthernet0/0/2]int g0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 20
[SW2-GigabitEthernet0/0/3]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
```
- **SW3**
```
[SW3]vlan batch 30 40
[SW3]int g0/0/2
[SW3-GigabitEthernet0/0/2]port link-type access
[SW3-GigabitEthernet0/0/2]port default vlan 30
[SW3-GigabitEthernet0/0/2]int g0/0/3
[SW3-GigabitEthernet0/0/3]port link-type access
[SW3-GigabitEthernet0/0/3]port default vlan 40
[SW3-GigabitEthernet0/0/3]int g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
```
### 二、DHCP
- **SW1**
```
[SW1]dhcp enable
[SW1]ip pool vlan10
[SW1-ip-pool-vlan10]network 192.168.100.0 mask 26
[SW1-ip-pool-vlan10]gateway-list 192.168.100.62
[SW1-ip-pool-vlan10]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan10]ip pool vlan20
[SW1-ip-pool-vlan20]network 192.168.100.64 mask 26
[SW1-ip-pool-vlan20]gateway-list 192.168.100.126
[SW1-ip-pool-vlan20]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan20]ip pool vlan30
[SW1-ip-pool-vlan30]network 192.168.100.128 mask 26
[SW1-ip-pool-vlan30]gateway-list 192.168.100.190
[SW1-ip-pool-vlan30]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan30]ip pool vlan40
[SW1-ip-pool-vlan40]network 192.168.100.192 mask 26
[SW1-ip-pool-vlan40]gateway-list 192.168.100.254
[SW1-ip-pool-vlan40]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan40]quit
[SW1]port-group group-member g0/0/1 g0/0/2
[SW1-port-group]port link-type trunk
[SW1-port-group]port trunk allow-pass vlan all
[SW1-port-group]quit
[SW1]vlan batch 10 20 30 40
[SW1]int vlan 10
[SW1-Vlanif10]ip add 192.168.100.62 26
[SW1-Vlanif10]dhcp select global
[SW1-Vlanif10]int vlan 20
[SW1-Vlanif20]ip add 192.168.100.126 26
[SW1-Vlanif20]dhcp select global
[SW1-Vlanif20]int vlan 30
[SW1-Vlanif30]ip add 192.168.100.190 26
[SW1-Vlanif30]dhcp select global
[SW1-Vlanif30]int vlan 40
[SW1-Vlanif40]ip add 192.168.100.254 26
[SW1-Vlanif40]dhcp select global
```
### 三、测试
- **PC1**
```
PC1>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe2c:74ae
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.61
Subnet mask.......................: 255.255.255.192
Gateway...........................: 192.168.100.62
Physical address..................: 54-89-98-2C-74-AE
DNS server........................: 223.5.5.5
223.6.6.6
```
- **PC2**
```
PC2>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe83:1712
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.125
Subnet mask.......................: 255.255.255.192
Gateway...........................: 192.168.100.126
Physical address..................: 54-89-98-83-17-12
DNS server........................: 223.5.5.5
223.6.6.6
```
- **PC3**
```
PC3>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe78:79be
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.189
Subnet mask.......................: 255.255.255.192
Gateway...........................: 192.168.100.190
Physical address..................: 54-89-98-78-79-BE
DNS server........................: 223.5.5.5
223.6.6.6
```
- **PC4**
```
PC4>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe38:46a7
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.253
Subnet mask.......................: 255.255.255.192
Gateway...........................: 192.168.100.254
Physical address..................: 54-89-98-38-46-A7
DNS server........................: 223.5.5.5
223.6.6.6
```
### 四、子网划分 - 非等分
![image-20240829141107888](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240829141107888.png)