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?

Michael May
  • 1,005
  • 2
  • 9
  • 21

3 Answers3

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;
        }
    }
}
ytti
  • 9,786
  • 44
  • 53
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
David Rothera
  • 2,798
  • 17
  • 20
-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.

Tim
  • 85
  • 1
  • 4