02-20-2022 10:49 AM
Hi, I have two vlans, but all the hosts connected to those vlans have the same subnet because it was previously assigned using DHCP, so my question is... can the two vlans have the same gateway?.. Or there is a way to use DHCP to assign IP addresses with different networks depending on the VLAN?
02-20-2022 11:33 AM
Hello,
the short answer is: no. each Vlan needs its own subnet. What exactly are you trying to accomplish ?
02-20-2022 12:09 PM
Hello
@sebas1234 wrote:
can the two vlans have the same gateway?..
No they cannot however a vlan can have multiple gateways.
@sebas1234 wrote:
Or there is a way to use DHCP to assign IP addresses with different networks depending on the VLAN?
yes there is:
example - rtr with multiple sub-interfaces
interface GigabitEthernet0/1
no shut
interface GigabitEthernet0/1.10
description vlan 10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
interface GigabitEthernet0/1.20
description vlan 20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
ip dhcp pool LAN
network 192.168.10.0 255.255.255.0
network 192.168.20.0 255.255.255.0 secondary
override default-router 192.168.20.1
default-router 192.168.10.1
dns-server 8.8.8.8 8.8.4.4
domain-name test.com
lease 0 8
02-21-2022 09:25 AM
Looking at the diagram, you would just make the two VLANs different subnets. The 20 VLAN could be 192.168.2.0/24 and the 30 VLAN could be 192.168.3.0/24. If you are stuck using the same subnet for both, I would look into VRFs. I have not configured DHCP on a VRF so I am not sure if that is a valid design. However, I would fix the design above to what I have recommended in the first place. The subnets could be in the RFC1918 address space so you are not limited to 192.168 subnets.
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