Cyber_Security_Notes/A. 第一阶段/拓扑练习/0823_DHCP+VLAN.md

81 lines
2.0 KiB
Markdown
Raw Normal View History

2024-08-23 18:11:58 +08:00
# DHCP + VLAN
![image-20240823172337746](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240823172337746.png)
### 一、配置二层交换机
- **SW2**
```
<Huawei>u t m
<Huawei>sys
[Huawei]sys SW2
[SW2]vlan 10
[SW2-vlan10]port-group 1
[SW2-port-group-1]group-member g0/0/2 g0/0/3
[SW2-port-group-1]port link-type access
[SW2-port-group-1]port default vlan 10
[SW2-port-group-1]quit
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/1]return
<SW2>save
```
- **SW3**
```
<Huawei>u t m
<Huawei>sys
[Huawei]sys SW3
[SW3]vlan 20
[SW3-vlan20]port-group 1
[SW3-port-group-1]group-member g0/0/2 g0/0/3
[SW3-port-group-1]port link-type access
[SW3-port-group-1]port default vlan 20
[SW3-port-group-1]quit
[SW3]int g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW3-GigabitEthernet0/0/1]return
<SW3>save
```
### 二、配置三层交换机
- **SW1**
```
<Huawei>u t m
<Huawei>sys
[Huawei]sys SW1
[SW1]port-group 1
[SW1-port-group-1]group-member g0/0/1 g0/0/2
[SW1-port-group-1]port link-type trunk
[SW1-port-group-1]port trunk allow-pass vlan all
[SW1-port-group-1]quit
[SW1]ip policy-based-route
[SW1]ip pool vlan10
[SW1-ip-pool-vlan10]network 192.168.10.0 mask 24
[SW1-ip-pool-vlan10]gateway-list 192.168.10.254
[SW1-ip-pool-vlan10]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan10]quit
[SW1]ip pool vlan20
[SW1-ip-pool-vlan20]network 192.168.20.0 mask 24
[SW1-ip-pool-vlan20]gateway-list 192.168.20.254
[SW1-ip-pool-vlan20]dns-list 223.5.5.5 223.6.6.6
[SW1-ip-pool-vlan20]quit
[SW1]dhcp enable
[SW1]vlan batch 10 20
[SW1]int vlanif 10
[SW1-Vlanif10]ip a 192.168.10.254 24
[SW1-Vlanif10]dhcp select global
[SW1-Vlanif10]int vlanif 20
[SW1-Vlanif20]ip a 192.168.20.254 24
[SW1-Vlanif20]dhcp select global
[SW1-Vlanif20]return
<SW1>save
```