01-06-2013 03:59 AM
I have a switch that has 2 VLANS: vlan 2 and vlan 3 - and two PCs are connected to the switch where each PC is a member of one of the VLANs.
PC2 = VLAN2
PC3 = VLAN3
The switch is connected to a router that acts as a DHCP server with multiple 3 DHCP scopes for each of the VLANS, basically a simple "router on a stick" configuration. This question has been baffling me for a while: how does the router knows which dhcp scope to allocate an IP address from to a particular PC?
Let's say PC2 is now trying to get an IP address from the DHCP server, I know initially that it will send a DHCP DISCOVER broadcast message to the the router and I presume that the router will know the VLAN that the request came from as well based on information in the packet. But how does the router discern which scope to allocate IP address to PC2 especially if I need PC2 to have an IP address in subnet 192.168.2.0 and NOT from 192.168.3.0 or vice versa?? What controls such a selection?
IP dhcp pool vlan1
ip dhcp excluded-address 192.168.2.1 192.168.2.10
ip dhcp excluded-address 192.168.3.1 192.168.3.10
!
ip dhcp pool vlan2
network 192.168.2.0 255.255.255.0
domain-name test.com
dns-server 192.168.2.1
default-router 192.168.2.1
!
ip dhcp pool vlan3
network 192.168.3.0 255.255.255.0
domain-name test.com
dns-server 192.168.2.1
default-router 192.168.3.1
thx sc.
Solved! Go to Solution.
01-06-2013 05:17 AM
Hi Sherwin,
This is will be very simple. I assume on the your router on stick configuration will have some thing like as below.
int fas 0/0.2
encapsulation dot1q 2
ip address 192.168.2.1 255.255.255.0
int fas 0/0.3
encapsulation dot1q 3
ip address 192.168.3.1 255.255.255.0
Now when a PC which is connected to VLAN 2 send a DHCP broadcast this broadcast will be received only by the interface which belongs to the same broadcast domain (VLAN 2). This broadcast is received by the sub interface Fas 0/0.2 as well as this has encapsulation dot1q 2 and hence it will be part of the same broadcast domain (VLAN 2). So the router will look if there is any DHCP scope configured for the ip range which it has on sub interface Fas 0/0.2. Router now knows about the 192.168.2.0 DHCP scope and will issue the IP range from this scope to any PC's in VLAN2.
Hope this helps.
Regards
Najaf
Please rate when applicable or helpful !!!
01-06-2013 05:17 AM
Hi Sherwin,
This is will be very simple. I assume on the your router on stick configuration will have some thing like as below.
int fas 0/0.2
encapsulation dot1q 2
ip address 192.168.2.1 255.255.255.0
int fas 0/0.3
encapsulation dot1q 3
ip address 192.168.3.1 255.255.255.0
Now when a PC which is connected to VLAN 2 send a DHCP broadcast this broadcast will be received only by the interface which belongs to the same broadcast domain (VLAN 2). This broadcast is received by the sub interface Fas 0/0.2 as well as this has encapsulation dot1q 2 and hence it will be part of the same broadcast domain (VLAN 2). So the router will look if there is any DHCP scope configured for the ip range which it has on sub interface Fas 0/0.2. Router now knows about the 192.168.2.0 DHCP scope and will issue the IP range from this scope to any PC's in VLAN2.
Hope this helps.
Regards
Najaf
Please rate when applicable or helpful !!!
01-13-2013 05:57 AM
Ahhhh!!! Thx very much i think you explained it quite well. I know there was a connection somewhere but I just couldn't find it. once again thx.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide