OpenWRT mit VLAN
Die Idee war, innerhalb einer abgesicherten Umgebung (Heimnetz hinter Fritz!Box) eine
Trennung mit einem NanoPi R3S (zwei LAN-Ports) und VLAN-tauglichem Switch mehrere Sicherheitszonen zu schaffen.
Das WAN-Interface auf dem NanoPi ist eth0; das LAN-Interface eth1. Über letzteres werden die VLAN 200, 300, 400 und 500
auf den Port 1 als Trunkport eines Netgear GS105E geleitet.
Die Ports 2 bis 5 entsprechend dann den konfigurierten Bereichen mit derselben Nummer. Die Ports 2 bis 5 sind dann "untagged" in die VLAN 200 bis 500.
Auf dem WAN-Interface ist "Masquerading" abgeschaltet; somit müssen auf der Fritz!Box statische Routen zu den
vier zusätzlichen Netzen 192.168.20.0/24, 192.168.30.0/24, 192.168.40.0/24 und 192.168.50.0/24 eingerichtet
werden. Ziel ist dann die IP-Adresse des WAN-Interfaces, die der NanoPi per DHCP von der Fritz!Box erhalten hat.
Dieses kann entfallen, wenn die Firewall alle hinter ihr liegenden Systeme hinter der eigenen IP-Adresse "versteckt".
Nur in der Area2 ist die Administration der Firewall freigeschaltet; alle Systeme in den Zonen 3-5 dürfen
ausschließlich für DNS (Port 53) und DHCP (Ports 67 und 68) auf den NanoPi zugreifen.
Die Konfiguration ist eigentlich einfach und übersichtlich; wird hier jetzt aber dokumentiert,
weil sie mir doch nicht so leicht fiel, wie ich naiverweise zuerst angenommen hatte.
"DSA" (Distributed Switch Architecture) ist zwar seit ca. 2015 im Linux-Kernel verfügbar;
war mir aber noch nicht vorher so untergekommen.
/etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd67:db09:xxxx::/48'
option packet_steering '1'
config device
option name 'eth0'
option macaddr 'xx:xx:xx:xx:8e:69'
config interface 'wan'
option device 'eth0'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0'
option proto 'dhcpv6'
config device
option name 'eth1'
option macaddr 'xx:xx:xx:xx:8e:6a'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
config bridge-vlan
option device 'br-lan'
option vlan '200'
list ports 'eth1:t'
config bridge-vlan
option device 'br-lan'
option vlan '300'
list ports 'eth1:t'
config bridge-vlan
option device 'br-lan'
option vlan '400'
list ports 'eth1:t'
config bridge-vlan
option device 'br-lan'
option vlan '500'
list ports 'eth1:t'
config interface 'intArea2'
option proto 'static'
option device 'br-lan.200'
option ipaddr '192.168.20.1'
option netmask '255.255.255.0'
config interface 'intArea3'
option proto 'static'
option device 'br-lan.300'
option ipaddr '192.168.30.1'
option netmask '255.255.255.0'
config interface 'intArea4'
option proto 'static'
option device 'br-lan.400'
option ipaddr '192.168.40.1'
option netmask '255.255.255.0'
config interface 'intArea5'
option proto 'static'
option device 'br-lan.500'
option ipaddr '192.168.50.1'
option netmask '255.255.255.0'
/etc/config/firewall
config defaults
option input 'REJECT'
option output 'ACCEPT'
option forward 'DROP'
option synflood_protect '1'
config zone
option name 'ZoneArea2'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'DROP'
list network 'intArea2'
config zone
option name 'ZoneArea3'
option input 'REJECT'
option output 'ACCEPT'
option forward 'DROP'
list network 'intArea3'
config zone
option name 'ZoneArea4'
option input 'REJECT'
option output 'ACCEPT'
option forward 'DROP'
list network 'intArea4'
config zone
option name 'ZoneArea5'
option input 'REJECT'
option output 'ACCEPT'
option forward 'DROP'
list network 'intArea5'
config zone
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option mtu_fix '1'
list network 'wan'
list network 'wan6'
config forwarding
option src 'ZoneArea2'
option dest 'wan'
config forwarding
option src 'ZoneArea3'
option dest 'wan'
config forwarding
option src 'ZoneArea4'
option dest 'wan'
config forwarding
option src 'ZoneArea5'
option dest 'wan'
config rule
option name 'dns_dhcp'
option src 'ZoneArea3'
option dest_port '53 67 68'
option target 'ACCEPT'
config rule
option name 'dns_dhcp'
option src 'ZoneArea4'
option dest_port '53 67 68'
option target 'ACCEPT'
config rule
option name 'dns_dhcp'
option src 'ZoneArea5'
option dest_port '53 67 68'
option target 'ACCEPT'
/etc/config/dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option nonegcache '0'
option cachesize '1000'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
option nonwildcard '1'
option localservice '1'
option ednspacket_max '1232'
option filter_aaaa '0'
option filter_a '0'
config dhcp 'wan'
option interface 'wan'
option ignore '1'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'
config dhcp 'intArea2'
option interface 'intArea2'
option start '100'
option limit '150'
option leasetime '12h'
option ra 'server'
config dhcp 'intArea3'
option interface 'intArea3'
option start '100'
option limit '150'
option leasetime '12h'
option ra 'server'
config dhcp 'intArea4'
option interface 'intArea4'
option start '100'
option limit '150'
option leasetime '12h'
config dhcp 'intArea5'
option interface 'intArea5'
option start '100'
option limit '150'
option leasetime '12h'
/etc/config/system
config system
option hostname 'OpenWrt'
option timezone 'CET-1CEST,M3.5.0,M10.5.0/3'
option ttylogin '0'
option log_size '128'
option urandom_seed '0'
option zonename 'Europe/Berlin'
option log_proto 'udp'
option conloglevel '8'
option cronloglevel '7'
config timeserver 'ntp'
list server '0.openwrt.pool.ntp.org'
list server '1.openwrt.pool.ntp.org'
list server '2.openwrt.pool.ntp.org'
list server '3.openwrt.pool.ntp.org'
config led 'led_wan'
option name 'WAN'
option sysfs 'green:wan'
option trigger 'netdev'
option mode 'link tx rx'
option dev 'eth0'
config led 'led_lan'
option name 'LAN'
option sysfs 'green:lan'
option trigger 'netdev'
option mode 'link tx rx'
option dev 'eth1'
Performance
Bei einfachen Lasttests ist es mir weder gelungen den NanoPi "ins schwitzen" zu bekommen, noch messbare Latenz oder gar Bandbreitenreduzierungen zu erreichen.
Erschreckendes
Etwas erschrocken war ich, als ich in der Admin-Oberfläche der Firewall gesehen habe, wieviele Kommunikationsbeziehungen mein Rechner Richtung Internet regelmäßig nutzt. Etwas beruhigter war ich, als ich über die Zieladressen im Internet die Dienste relativ leicht identifizieren konnte.
Fazit
Für eine Segmentierung des Heimnetzes ist heute alles preiswert verfügbar und mit vertretbarem Aufwand
auch konfigurierbar.
|