OpenWrt 라우터 문서 신규: HAProxy, nftables CDN 필터, named set

This commit is contained in:
kappa
2026-03-25 16:31:37 +09:00
parent 27ab321bfb
commit 77d7108206

75
infra/openwrt.md Normal file
View File

@@ -0,0 +1,75 @@
---
title: OpenWrt 라우터 (서울)
updated: 2026-03-25
tags: [openwrt, haproxy, nftables, firewall]
---
## 호스트 정보
| 항목 | 값 |
|------|-----|
| SSH | `root@100.66.60.66` (openwrt-gw) |
| 모델 | FUJITSU FMVC04004 |
| CPU | AMD GX-222GC 2코어 2GHz |
| RAM | 3.6GB |
| NIC | 1Gbps x2 (eth0: br-lan, eth1: WAN) |
| OS | OpenWrt (x86_64, 커널 6.12) |
## HAProxy
설정 파일: `/etc/haproxy.cfg`
stats: `:9999` (admin/admin)
maxconn: 20000
### 포트 매핑
| Frontend | Port | Backend | 대상 | 용도 |
|----------|------|---------|------|------|
| ft_http | :80 | bk_traefik_http | 3노드 :80 roundrobin | Traefik 메인 라우팅 |
| ft_https | :443 | bk_traefik_https | 3노드 :443 roundrobin | Traefik 메인 라우팅 |
| ft_apisix_http | :9080 | bk_apisix_http | 3노드 :30233 roundrobin | APISIX SafeLine WAF |
| ft_apisix_https | :9443 | bk_apisix_https | 3노드 :31137 roundrobin | APISIX SafeLine WAF |
백엔드 노드: incus-kr2(192.168.9.135), incus-kr1(192.168.9.214), incus-hp2(192.168.9.134)
## nftables 방화벽
### CDN IP 필터 (`/etc/nftables.d/10-cdn-filter.nft`)
named set 방식으로 BunnyCDN + Cloudflare IP를 관리. 80/443/9080/9443 포트에 대해 CDN IP만 허용, WAN 직접 접근 차단.
```
set cdn_ipv4 { type ipv4_addr; flags interval; elements = { BunnyCDN IPs + Cloudflare IPv4 CIDRs } }
set cdn_ipv6 { type ipv6_addr; flags interval; elements = { Cloudflare IPv6 CIDRs } }
chain cdn_filter {
tcp dport { 80, 443, 9080, 9443 } ip saddr @cdn_ipv4 accept
udp dport 443 ip saddr @cdn_ipv4 accept
tcp dport { 80, 443, 9080, 9443 } ip6 saddr @cdn_ipv6 accept
udp dport 443 ip6 saddr @cdn_ipv6 accept
tcp dport { 80, 443, 9080, 9443 } iifname "eth1" drop
udp dport 443 iifname "eth1" drop
}
```
### CDN IP 갱신 스크립트 (`/etc/cdn-filter-update.sh`)
BunnyCDN API + Cloudflare IP 목록을 다운로드하여 named set 재생성 → `fw4 restart`. 수동 실행: `sh /etc/cdn-filter-update.sh`
### QUIC 로드밸런싱 (`table ip quic_lb`)
nftables DNAT으로 UDP 443을 3노드 APISIX :9443에 round-robin 분배.
### NAT Reflection (`dstnat_lan`)
LAN(192.168.1.0/24, 192.168.9.0/24)에서 공인IP(220.120.65.245)로 접근 시 192.168.9.1(라우터)로 DNAT → HAProxy 경유.
### WAN DNAT (`dstnat_wan`)
WAN TCP 80/443 → 192.168.9.1:80/443 (HAProxy)로 DNAT.
## 관련 문서
- [[infra-hosts]] — 서버 목록
- [[apisix]] — APISIX 설정
- [[gateway-api]] — Traefik Gateway API