13

Many have pointed out that a VLAN can hold one or more subnets. If your default gateway for this subnet is on a router or a L3 switch then how could there be more than one default gateway in a VLAN configuration? On a router you map each subinterface to a VLAN and give it an IP and you can't have two subinterfaces with the same VLAN. On a L3 switch you give the VLAN interface an IP and that acts as the default gateway; you can't give it two IPs. So, how would one go about including two subnets in one VLAN?

11

You can use secondary addressing to add another subnet onto a SVI, this is not recommended but can be used if you really need it.

Current configuration : 190 bytes
!
interface Vlan45
 ip address 2.3.4.5 255.255.255.0 secondary
 ip address 3.4.5.6 255.255.255.0 secondary
 ip address 4.5.6.7 255.255.255.0 secondary
 ip address 1.2.3.4 255.255.255.0
end
  • 3
    Elaborate why is it not recommended with source if possible. – ytti May 26 '13 at 11:05
  • 1
    It goes back to the old recommendation that you should limit the amount of hosts on any one broadcast domain to less than a certain amount, if you were to start adding more and more subnets to one broadcast domain you could end up actually slowing your network down due to the amount of broadcast traffic. – David Rothera May 26 '13 at 11:07
  • 2
    It would be then more accurate to state that it has nothing to do with amount of subnet but size of subnet, i.e. no recommendation against multiple subnets, 2*24 being equal to 1*23. – ytti May 26 '13 at 11:09
  • @DavidRothera, while this still holds true to a degree, people often get hung up on this old recommendation (emphasis added as I often still hear it mentioned in the same terms as 15+ years ago). When people were dealing with 10Mbps links and slow CPUs, this could easily be a serious drain on resources. When you are dealing with 100Mbps/1Gbps/10Gbps links, much faster multiple-core CPUs, and network interfaces that offload more of the work than ever, it isn't as big of a deal to enlarge the broadcast domain. – YLearn May 26 '13 at 13:58
  • 1
    I think, multiple subnets in one broadcast domain not advised, because of possibility of false presumption isolation of different subnets on L2 level. But in shown configuration, hosts from different subnets can communicate in bypass of L3 routing (and firewall). – mmv-ru Oct 6 '14 at 22:36
11

IOS example:

interface Vlan42
  ip address 192.0.2.1 255.255.255.0
  ip address 198.51.100.1 255.255.255.0 secondary
!

Now this Vlan42 can have two subnets

JunOS example:

vlan {
    unit 42 {
        family inet {
            address 192.0.2.1/24;
            address 198.51.100.1/24;
        }
    }
}
-3

The only down side to this is that it's not scalable as Cisco only allows one secondary IP address on the interface. You are much better sticking to the one subnet per VLAN idiom.

  • 3
    That is not correct, you can add many secondary addresses to an interface, it might not be recommended but it is possible. – David Rothera May 26 '13 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.