VLAN+DHCP(1)(附抓包)

實現給不一樣的vlan的主機分配IP地址。
【1】經過路由器實現
實驗步驟:
前提咱們要實現VLAN間的通訊
一、交換機的配置:
把各臺主機鏈接的接口分配到不一樣的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
二、路由器的配置
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抓的包。
相關文章
相關標籤/搜索