Ubuntu – How to configure two IP addresses on a specific vlan

networking

I'm not sure about the syntax here: what comes first in /etc/network/interfaces interface names, VLAN or alias? What I want is to setup two different subnets on the same VLAN (temporarily).

It will look something like below, where there's a 10.20.100.100/24 and 10.20.200.200/24 on the same VLAN (id 33):

iface eth0:1.33 inet static
  address 10.20.100.100
  netmask 255.255.255.0

iface eth0:2.33 inet static
  address 10.20.200.200
  netmask 255.255.255.0

I expected the Debian Wiki to answer this but it did not: https://wiki.debian.org/NetworkConfiguration#Multiple_IP_addresses_on_One_Interface

Best Answer

  • I don't know when and what changed, but you can now define virtual interfaces on vlans:

    auto eth0.10
    iface eth0.10 inet static
        address 192.168.1.61
        netmask 255.255.255.0
        gateway 192.168.1.11
    
    auto eth0.10:1
    iface eth0.10:1 inet static
        address 10.20.100.100
        netmask 255.255.255.0
    
    auto eth0.10:2
    iface eth0.10:2 inet static
        address 10.20.100.200
        netmask 255.255.255.0
    

    Think of vlan interfaces as physical interfaces. You add virtual interfaces to the "physical" interface.

  • Related Question