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 인터페이스에서 외부 NTP통신 허용
iot 인터페이스에서 라우터의 DHCP 허용
iot 인터페이스에서 라우터의 DNS 허용
iot 인터페이스에서 외부 DNS 접근차단

vi /etc/config/firewall에 추가
config rule
        option src 'iot'
        option dest 'lan'
        option name 'IOT-TO-LAN'
        list proto 'all'
        option target 'REJECT'

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-Block-External-DNS'
        option src 'iot'
        option dest 'wan'
        option proto 'tcp udp'
        option dest_port '53'
        option target 'REJECT'


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

** matter, tuya기기에서 약간의 트러블 있음.
** 일부 트러블이 있는 기기는 HA서버가 있는 메인 LAN 네트워크에 두는걸로 잠정해결.
** 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

방화벽 설정:
vi /etc/config/firewall
config rule
  option name 'IOT-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