Posts: 4
Joined: Thu Feb 18, 2016 5:16 pm

Raspbian Jessie VLAN dhcpd [jesssie is obsolete]

Thu Feb 18, 2016 7:44 pm

My first post.

I'm attempting to use VLANs on my Ethernet interfaces for my Raspberry Pi running Raspbian Jessie. The VLAN interfaces will work if I manually configure the interfaces using ifconfig. I cannot reboot the Pi and have the interfaces remain.

From studying postings I know the old way of doing this is to add entries into /etc/network/interfaces. This file apparently is not read by default now.

I can successfully set a static IP for eth0 for example by adding lines to the end of dhcpcd.conf.
interface eth0
static ip_address=

I cannot set VLAN interfaces or I don't know the proper syntax. I've tried coping the above changing to something like interface eth0.2 with no success.

How can this be done now with dhcpcd.conf? If not how do I change things such that /etc/network/interfaces is used?

I've looked around and haven't found an answer to this specific question. Any help would be appreciated.

Posts: 3
Joined: Wed Jun 01, 2016 3:41 pm
Location: Near Fort Worth, TX, USA

Re: Raspbian Jessie VLAN dhcpd

Thu Jun 23, 2016 5:14 am

I was having the same problem. New to Pi stuff I am building a home DNS/DHCP/NTP server from my old Pi model B. Not being new to Debian/Ubuntu/etc I was trying to set up two VLAN interfaces on eth0 and, while I got it to work, it was also requesting dynamic DHCP addresses for eth0, eth0.x and eth0.y and I wanted to stop that.

Much hair pulling and Googling later, I came across Pi2 gets static IP but also DHCP IP is assigned which gave me the answer - the raspberrypi-net-mods package and it's new network method of using Marple's dhcpcd.

So... in order to do the now "correct" thing of leaving /etc/network/interfaces alone and modifying /etc/dhcpcd.conf I came up with this. You still modify /etc/network/interfaces, but not as much. What you have to do is use it to create the VLAN interfaces so the dhcpcd can manipulate them.

So in /etc/network/interfaces, add lines to create your VLAN interfaces:

Code: Select all

# VLAN x Interface
auto eth0.x
iface eth0.x inet manual
    vlan-raw-device eth0

# VLAN y Interface
auto eth0.y
iface eth0.y inet manual
    vlan-raw-device eth0
Now in your /etc/dhcpcd.conf append the following:

Code: Select all

# Leave Physical interface alone
denyinterfaces eth0

# Static IP configuration for VLan x and y
interface eth0.x

interface eth0.y
static ip_address=yyy.yyy.yyy.yyy/mm
static routers=yyy.yyy.yyy.yyy
static domain_name_servers=yyy.yyy.yyy.yyy
Changing the above x's and y's to whatever value you need.

Check the dhcpcd and dhcpcd.conf man pages for other options you can use.
John H. Reinhardt

Return to “Raspberry Pi OS”