VLAN+DHCP(1)(附抓包)

实现给不同的vlan的主机分配IP地址。
【1】通过路由器实现
VLAN+DHCP(1)(附抓包)_第1张图片
实验步骤:
前提我们要实现VLAN间的通信
1、交换机的配置:
把各台主机连接的接口分配到不同的VLAN
interface FastEthernet0/1
 switchport access vlan 10
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 20
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 30
 switchport mode access
2、路由器的配置
hostname DHCP-server
!
!
interface FastEthernet0/0.10
 encapsulation dot1Q 10
 ip address 192.168.1.254 255.255.255.0
!
interface FastEthernet0/0.20
 encapsulation dot1Q 20
 ip address 192.168.2.254 255.255.255.0
!
interface FastEthernet0/0.30
 encapsulation dot1Q 30
 ip address 192.168.3.254 255.255.255.0
DHCP的配置
ip dhcp excluded-address 192.168.1.254
ip dhcp excluded-address 192.168.2.254
ip dhcp excluded-address 192.168.3.254
ip dhcp pool vlan10 //给vlan10创建地址池
network 192.168.1.0 255.255.255.0
default-getway 192.168.1.254
dhs-server 1.1.1.1
lease 3
ip dhcp pool vlan20  //给vlan20创建地址池
network 192.168.2.0 255.255.255.0
default-getway 192.168.2.254
dhs-server 1.1.1.1
lease 3
ip dhcp pool vlan30  //给vlan30创建地址池
network 192.168.3.0 255.255.255.0
default-getway 192.168.3.254
dhs-server 1.1.1.1
lease 3
测试:略。
【2】通过三层交换机实现
实验步骤:
interface FastEthernet0/1
 switchport access vlan 10
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 20
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 30
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 30
 switchport mode access
!
interface Vlan10
 ip address 192.168.1.1 255.255.255.0
!
interface Vlan20
 ip address 192.168.2.1 255.255.255.0
!
interface Vlan30
 ip address 192.168.3.1 255.255.255.0
!
ip classless
!
!
!
ip dhcp excluded-address 192.168.1.254
ip dhcp excluded-address 192.168.2.254
ip dhcp excluded-address 192.168.3.254
ip dhcp excluded-address 192.168.3.1 192.168.3.10
ip dhcp excluded-address 192.168.2.1 192.168.2.10
ip dhcp excluded-address 192.168.1.1 192.168.1.10
!
ip dhcp pool vlan10
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.254
 dns-server 1.1.1.1
ip dhcp pool vlan20
 network 192.168.2.0 255.255.255.0
 default-router 192.168.2.254
 dns-server 1.1.1.1
ip dhcp pool vlan30
 network 192.168.3.0 255.255.255.0
 default-router 192.168.3.254
 dns-server 1.1.1.1
测试:略。
附加:用wireshark抓的包。
 

你可能感兴趣的:(职场,DHCP,VLAN,休闲)