Skip to main content

Access point: trunk e VLAN

L'access point riceve dal router il trunk (Casa untagged, Lavoro/IoT/Ospiti tagged) e lo distribuisce su porte e SSID. Non fa routing, DHCP o firewall.

Prerequisiti ("dumb AP")

uci set network.lan.proto='static'
uci set network.lan.ipaddr='192.168.10.2'
uci set network.lan.netmask='255.255.255.0'
uci set network.lan.gateway='192.168.10.1'
uci add_list network.lan.dns='192.168.10.1'
uci set dhcp.lan.ignore='1'

Individuare la porta del trunk

Sul router:

bridge fdb show br br-lan | grep -i <MAC dell'AP>

Nell'esempio il cavo entra in lan1 dell'AP.

Se usi la porta wan dell'AP come uplink, aggiungila prima al bridge (uci add_list network.<sezione br-lan>.ports='wan') e usala al posto di lan1.

Configurazione

# Casa (10): nativa sul trunk + porte access
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='br-lan'
uci set network.@bridge-vlan[-1].vlan='10'
uci add_list network.@bridge-vlan[-1].ports='lan1:u*'
uci add_list network.@bridge-vlan[-1].ports='lan3:u*'
uci add_list network.@bridge-vlan[-1].ports='lan4:u*'

# Lavoro (20) e Ospiti (40): solo trunk (arrivano via Wi-Fi)
for v in 20 40; do
  uci add network bridge-vlan
  uci set network.@bridge-vlan[-1].device='br-lan'
  uci set network.@bridge-vlan[-1].vlan="$v"
  uci add_list network.@bridge-vlan[-1].ports='lan1:t'
done

# IoT (30): trunk + porta access per un hub
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='br-lan'
uci set network.@bridge-vlan[-1].vlan='30'
uci add_list network.@bridge-vlan[-1].ports='lan1:t'
uci add_list network.@bridge-vlan[-1].ports='lan2:u*'

# Interfacce
uci set network.lan.device='br-lan.10'          # FONDAMENTALE
for n in "work 20" "iot 30" "guest 40"; do
  set -- $n
  uci set network.$1=interface
  uci set network.$1.proto='none'
  uci set network.$1.device="br-lan.$2"
done

uci changes network

Applica con il ripristino automatico, poi verifica:

bridge vlan show
ping -c 3 192.168.10.1
touch /tmp/ok

Gli SSID si aggiungono nella pagina Wi-Fi.

Variante: trunk "tutto tagged"

Alcuni preferiscono che sul trunk nessuna VLAN viaggi untagged. Il passaggio da nativa a tagged va fatto su entrambi i lati quasi in contemporanea, perché nel frattempo l'AP non è raggiungibile:

  1. Apri una sessione SSH sul router e una sull'AP.
  2. Prepara su entrambi, senza commit:
    V=$(uci show network | sed -n "s/^network\.\([^.]*\)\.vlan='10'$/\1/p")
    uci del_list network.$V.ports='PORTA_TRUNK:u*'
    uci add_list network.$V.ports='PORTA_TRUNK:t'
    
    (lan4 sul router, lan1 sull'AP nell'esempio)
  3. Attiva il ripristino automatico con sleep 300 su entrambi.
  4. Applica prima sull'AP, poi subito sul router.
  5. Dal router: ping 192.168.10.2.
  6. Conferma con touch /tmp/ok prima sull'AP, poi sul router.

Se l'AP non risponde, non confermare nulla: dopo 5 minuti entrambi tornano indietro e restano compatibili. Se confermassi solo il router, i due lati non si parlerebbero più.

Porte inutilizzate

Per impedire collegamenti non autorizzati, togli una porta da tutte le VLAN ma lasciala nel bridge: con il VLAN filtering attivo scarta tutto il traffico.

V=$(uci show network | sed -n "s/^network\.\([^.]*\)\.vlan='10'$/\1/p")
uci del_list network.$V.ports='lan4:u*'