[ale] dhcpd to multiple vlans from one server

Phil Turmel philip at turmel.org
Thu Jan 22 20:03:11 EST 2015


On 01/22/2015 07:37 PM, Robert L. Harris wrote:
> Ok, so if I have 2 subnets:
> 
> 172.20.1/24 on vlan 21
> 172.20.2/24 on vlan 22
> 
> If a host plugs into a port assigned to vlan 22, how do I make sure dhcpd
> gives out the right address?  That's the part of the designation I'm
> missing.

I can't help with dhcpd, but I do have this working in a small network
w/ dnsmasq.  The key is to configure the host to break tagged vlan
traffic into independent interfaces (eth0.21, eth0.22 ...) and make sure
dnsmasq is listening on them.  In the dnsmasq config, each address range
is marked with the interface (vlan) that it should respond to.

Oh, and the switch needs to send on *tagged* packets on the host's port.

Some snippets for you (gentoo, w/ bridge & bond config too):

/etc/conf.d/net :

# lan2 & lan3 are connected to two switch ports in link aggregation
# mode, with vlan tagged packets only
config_lan2="null"
config_lan3="null"
slaves_bond0="lan2 lan3"
config_bond0="null"
mode_bond0="balance-rr"
miimon_bond0="100"
use_carrier_bond0="1"
rc_net_bond0_provide="!net"

vlans_bond0="1 10 11"
config_bond0_1="null"
config_bond0_10="null"
config_bond0_11="null"

# The office LAN is configured to use 192.168.19.0/24 on
# VLAN #1 through the bonded lan ports.
bridge_br0="tap0 bond0.1"
config_tap0="null"
brctl_br0="stp off"
config_br0="192.168.19.1/24 192.168.19.2/24 192.168.19.3/24
192.168.19.254/24"
rc_net_br0_need="net.tap0 net.bond0"

# Customer sim network ...
# 172.29.0.0/16 on VLAN #10.
bridge_br1="tap1 bond0.10"
tuntap_tap1="tap"
config_tap1="null"
brctl_br1="stp off"
config_br1="172.29.0.1/16"
rc_net_br1_need="net.tap1 net.bond0"

# Customer sim network ...
# 172.30.0.0/16 on VLAN #11.
bridge_br2="tap2 bond0.11"
tuntap_tap2="tap"
config_tap2="null"
brctl_br2="stp off"
config_br2="172.30.0.1/16"
rc_net_br2_need="net.tap2 net.bond0"


/etc/dnsmasq.conf :

# Pass out dynamic IP addresses
interface=br0
dhcp-range=br0,192.168.19.160,192.168.19.199,6h
dhcp-option=br0,1,255.255.255.0   # Subnet mask
dhcp-option=br0,3,192.168.19.2    # Default gateway
dhcp-option=br0,6,192.168.19.2    # DNS Server
dhcp-option=br0,28,192.168.19.255 # Broadcast address
dhcp-option=br0,42,192.168.19.2   # NTP Server
dhcp-option=br0,44,192.168.19.2   # set netbios-over-TCP/IP
nameserver(s) aka WINS server(s)
dhcp-option=br0,45,192.168.19.2   # netbios datagram distribution server

interface=br1
dhcp-range=br1,172.29.1.5,172.29.1.250,24h
dhcp-option=br1,1,255.255.0.0     # Subnet mask
dhcp-option=br1,3                 # Default gateway
dhcp-option=br1,6                 # DNS Server
dhcp-option=br1,28,172.29.255.255 # Broadcast address
dhcp-option=br1,42,172.29.0.1     # NTP Server

interface=br2
dhcp-range=br2,172.30.1.5,172.30.1.250,24h
dhcp-option=br2,1,255.255.0.0     # Subnet mask
dhcp-option=br2,3,172.30.0.1      # Default gateway
dhcp-option=br2,6,172.30.0.1      # DNS Server
dhcp-option=br2,28,172.30.255.255 # Broadcast address
dhcp-option=br2,42,172.30.0.1     # NTP Server

dhcp-option=46,8   # netbios node type
dhcp-option=47     # empty netbios scope.
dhcp-authoritative


::::::::::::::
Note how the address range and most options are marked with the bridge
interface they must work with, while a couple global options apply to
any interface.

HTH,

Phil


More information about the Ale mailing list