2025/12/13

OpenWRT Wifi 망분리



LAN 네트워크: 192.168.1.0
IoT 네트워크: 192.168.2.0 으로 분리
망분리는 사물인터넷망에 연결된 장치가 메인 LAN 네트워크에 접근하는 것을 차단하면서, 인터넷 접근만 허용하는 것이 목표.


1. 새로운 브리지 장치 생성

Network/Interfaces/Devices/Add device configuraiton...

Device type: Bridge device
Device name: br-iot
Bring up empty bridge 체크
나머진 그대로 두고 저장


2. iot 네트워크 인터페이스 생성

Network/Interfaces/Interfaces/Add new interface...

Name: iot
Protocol: Static address
Device: br-iot
저장 후 새로만든 iot interface 편집

Interface iot/General Settings 탭:
IPv4 address: 192.168.2.1
IPv4 netmask: 255.255.255.0

Interface iot/Firewall Settings 탭:
-- custom -- 필드에 iot입력

Interface iot/DHCP Server/General Setup 탭:
Ignore interface 체크해제
저장 후 적용


3. 무선(Wi-Fi) 설정

Network/Wireless
ax/b/g/n radio옆의 add버튼으로 2.4G wifi 네트워크 추가
ac/ax/n radio옆의 add버튼으로 5G wifi 네트워크 추가

2.4G Interface Configuration에서
Mode: Access Point
ESSID: iot2
Network: iot

5G Interface Configuration에서
Mode: Access Point
ESSID: iot5
Network: iot

Wireless Security 설정후 저장하고 적용.


4. 방화벽 규칙 설정

Network/Firewall/General Settings 탭:

iot 영역 편집
Input: reject
Output: accept
Intra zone forward: reject
Allow forward to destination zones: wan
Allow forward from source zones: lan

lan 영역 편집
Input: accept
Output: accept
Intra zone forward: accept
Allow forward to destination zones: iot,wan
Allow forward from source zones:

Network/Firewall/Traffic Rules 탭:
iot 인터페이스에서 lan으로 응답 트래픽 허용
iot 인터페이스에서 HA서버 허용
iot 인터페이스에서 외부 NTP통신 허용
iot 인터페이스에서 라우터의 DHCP 허용
iot 인터페이스에서 라우터의 DNS 허용
iot 인터페이스에서 DHCPv6 허용

vi /etc/config/firewall에 추가
config rule
        option name 'IOT-to-LAN-Established'
        option src 'iot'
        option dest 'lan'
        option target 'ACCEPT'
        option connection_status 'established related'

config rule
        option name 'IOT-to-HA'
        option src 'iot'
        option dest 'lan'
        option dest_ip '192.168.1.5'
        option dest_port '8123'
        option proto 'tcp'
        option target 'ACCEPT'

config rule
        option name 'IOT-to-NTP'
        option src 'iot'
        option proto 'udp'
        option dest_port '123'
        option target 'ACCEPT'

config rule
        option src 'iot'
        option name 'IOT-to-DHCP'
        list proto 'udp'
        option src_port '68'
        option dest_port '67'
        option target 'ACCEPT'

config rule
        option name 'IOT-to-DNS'
        option src 'iot'
        option proto 'tcp udp'
        option dest_port '53'
        option target 'ACCEPT'

config rule
        option name 'IOT-to-DHCPv6'
        option src 'iot'
        list proto 'udp'
        option src_port '546'
        option dest_port '547'
        option family 'ipv6'
        option target 'ACCEPT'

이후 메인 LAN망에 접속된 iot기기를 ssid 변경하고 iot망으로 이전



** matter over wifi, tuya local 기기 등록에 트러블 있음.
** tuya matter 디바이스는 등록시 외부 DNS를 허용할 것.
** 일부 트러블이 있는 matter over wifi 기기는 HA서버가 있는 메인 LAN 네트워크에 두는걸로 잠정해결.
** luci-app-sqm 패키지 설치 - 네트워크 인터페이스별로 QoS 적용.
** mDNS reflector(Avahi) 설치 - eshome등에서 기기 자동발견을 사용하려면 필요.
패키지 설치:
opkg update
opkg install avahi-daemon avahi-utils

Avahi 설정:
vi /etc/avahi/avahi-daemon.conf
[server]
allow-interfaces=br-lan,br-iot
[reflector]
enable-reflector=yes

upnpd 설정:
vi /etc/config/unpnpd
config upnpd 'config'
    list internal_iface 'iot'
    option ipv6_disable '0'
 
방화벽 설정:
vi /etc/config/firewall
config rule
        option name 'IOT-to-mDNS'
        option src 'iot'
        option proto 'udp'
        option dest_port '5353'
        option target 'ACCEPT'

서비스 재시작:
/etc/init.d/avahi-daemon enable
/etc/init.d/avahi-daemon restart
/etc/init.d/firewall restart
** ipv6 설정
iot인터페이스/고급설정
IPv6 assignment length: 64
IPv6 assignment hint: 1
iot인터페이스/DHCP 서버/IPv6 설정
RA-서비스: 서버모드
DHCPv6 서비스: 서버모드
Local IPv6 DNS server: 체크
iot인터페이스/DHCP 서버/IPv6 RA Settings
Default router: forced
SLAAC 활성화: 체크