Berikut cara konfigurasi DHCP Server di switch Layer-3 (Cisco) supaya PC di VLAN bisa dapat IP otomatis.
Contoh skenario
- VLAN 10 (USER) :
192.168.10.0/24gateway192.168.10.1 - VLAN 20 (HR) :
192.168.20.0/24gateway192.168.20.1 - Switch L3 jadi gateway + DHCP server
1) Buat VLAN & SVI (gateway) + aktifkan routing
conf t
ip routing
vlan 10
name USER
vlan 20
name HR
interface vlan 10
ip address 192.168.10.1 255.255.255.0
no shutdown
interface vlan 20
ip address 192.168.20.1 255.255.255.0
no shutdown
end
Cek:
show ip interface brief
show vlan brief
2) Set port user jadi access ke VLAN masing-masing
conf t
interface range fa0/1 - 12
switchport mode access
switchport access vlan 10
spanning-tree portfast
interface range fa0/13 - 24
switchport mode access
switchport access vlan 20
spanning-tree portfast
end
3) Konfigurasi DHCP (exclude + pool)
Exclude IP (biar tidak dipinjamkan DHCP)
conf t
ip dhcp excluded-address 192.168.10.1 192.168.10.20
ip dhcp excluded-address 192.168.20.1 192.168.20.20
end
Buat DHCP pool per VLAN
conf t
ip dhcp pool VLAN10-USER
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 8.8.8.8 1.1.1.1
lease 7
ip dhcp pool VLAN20-HR
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
dns-server 8.8.8.8 1.1.1.1
lease 7
end
wr mem
4) Verifikasi DHCP bekerja
show ip dhcp pool
show ip dhcp binding
show ip dhcp server statistics
show running-config | section dhcp
Catatan penting (sering bikin gagal)
- Pastikan PC mendapat IP via DHCP (auto).
- Pastikan SVI up/up (SVI akan up kalau ada minimal 1 port VLAN itu yang up).
- Kalau DHCP server bukan di switch ini (mis. server terpisah), di SVI pakai:
interface vlan 10 ip helper-address <IP_DHCP_SERVER>(Kalau DHCP sudah di switch L3 yang sama, tidak perlu helper-address.)
Kalau kamu kasih model switch (mis. 3560/3750/3650/9300) + VLAN & subnet yang kamu pakai, aku bikinkan konfigurasi persis sesuai topologi kamu (termasuk trunk/uplink kalau ada).
