FreeBSD: VLAN Interface Setup

How to set up VLAN interfaces (IEEE 802.1Q) within the FreeBSD

This example considers two physical network cards rl0 for LAN connection and re0 for WAN connection. The LAN connection uses native Ethernet encapsulation, whereas the WAN interface utilizes 802.1Q frame tagging with two VLANs, one for VLAN IPv4 and one for IPv6 connectivity. The example does not represent a router, but a general network device (desktop PC), which has access to the public network via WAN connection and access to some private resources via LAN connection.

Edit /etc/rc.conf and insert the following:

# Disable IPv6 by default
# ipv6_enable is obsolete. Use ipv6_activate_all_interfaces instead.
ipv6_activate_all_interfaces="NO"
# router solicitation daemon
rtsold_enable="NO"

# Having two network cards, but not a packet forwarder
gateway_enable="NO"
ipv6_gateway_enable="NO"

# Hostaname:
hostname="SERVER.DOMAIN.TLD"

# IPv4 for LAN:
ifconfig_rl0_name="lan"
#ifconfig_lan="up"
ifconfig_lan="LAN_IPv4_ADDRESS/LAN_PREFIX"
static_routes="internal1"
route_internal1="-net IPv4_ROUTE/LAN_PREFIX LAN_GATEWAY"
#defaultrouter="LAN_GATEWAY"

# VLAN, IPv4 and IPv6 for WAN:
ifconfig_re0_name="wan"
ifconfig_wan="up"
cloned_interfaces="vlan123 vlan456"
ifconfig_vlan123_name="wan4"
ifconfig_vlan456_name="wan6"
ipv6_network_interfaces="wan"
ifconfig_wan4="inet WAN4_IPv4_ADDRESS netmask WAN4_IPv4_NETMASK vlan 123 vlandev wan"
defaultrouter="WAN4_GATEWAY"
ifconfig_wan6="inet 169.256.12.34 netmask 255.255.0.0 vlan 456 vlandev wan"
ifconfig_wan6_ipv6="inet6 WAN6_IPv6_ADDRESS prefixlen 64 vlan 456 vlandev wan"
ipv6_defaultrouter="WAN6_GATEWAY"

The example is pretty much easy to understand. The LAN connection is a general static IP interface setup with an included static route (internal1). The WAN connection is configured using VLANs, as the ISP requests that, and it is split into a subinterface WAN4 (for IPv4 connectivity) and a subinterface WAN6 (for IPv6 connectivity with a Link-Local/APIPA fallback IPv4 address).

Advertisements
This entry was posted in BSD, Server and tagged , , , , , , . Bookmark the permalink.