# 기본 초기 설정 스크립트 예시 # 호스트네임 설정 /system identity set name="MyRouter" # 관리자 계정 비밀번호 변경 /user set [find name=admin] password="StrongPassword123" # WAN 인터페이스 이름 변경 (예: ether1 → WAN) /interface ethernet set [find default-name=ether1] name=WAN # LAN 인터페이스 이름 변경 (예: ether2 → LAN) /interface ethernet set [find default-name=ether2] name=LAN # LAN IP 주소 설정 /ip address add address=192.168.88.1/24 interface=LAN # DHCP 서버 설정 /ip pool add name=dhcp_pool ranges=192.168.88.10-192.168.88.100 /ip dhcp-server add name=dhcp1 interface=LAN address-pool=dhcp_pool lease-time=1d /ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 # DNS 설정 /ip dns set servers=8.8.8.8,1.1.1.1 allow-remote-requests=yes # NAT 설정 (LAN → WAN 인터넷 공유) /ip firewall nat add chain=srcnat out-interface=WAN action=masquerade # 기본 방화벽 규칙 (필요시 추가) /ip firewall filter add chain=input connection-state=established,related action=accept /ip firewall filter add chain=input connection-state=invalid action=drop /ip firewall filter add chain=input in-interface=WAN action=drop # 로그 설정 (필요시) /system logging add topics=firewall action=memory # 호스트네임 설정 /system identity set name="WG-Router" # 인터페이스 이름 변경 /interface ethernet set [find default-name=ether1] name=WAN /interface ethernet set [find default-name=ether2] name=LAN1 /interface ethernet set [find default-name=ether3] name=LAN2 /interface ethernet set [find default-name=ether4] name=LAN3 # LAN IP 주소 설정 /ip address add address=192.168.1.1/24 interface=LAN1 /ip address add address=192.168.1.1/24 interface=LAN2 /ip address add address=192.168.1.1/24 interface=LAN3 # DHCP 서버 설정 (LAN1 기준) /ip pool add name=dhcp_pool ranges=192.168.1.10-192.168.1.100 /ip dhcp-server add name=dhcp1 interface=LAN1 address-pool=dhcp_pool lease-time=1d /ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 dns-server=192.168.1.1 # DNS 설정 /ip dns set servers=8.8.8.8,1.1.1.1 allow-remote-requests=yes # NAT 설정 (LAN → WAN 인터넷 공유) /ip firewall nat add chain=srcnat out-interface=WAN action=masquerade # WireGuard 인터페이스 생성 /interface wireguard add name=wg0 listen-port=51820 private-key="서버프라이빗키" # WireGuard 서버 IP 설정 /ip address add address=10.10.10.1/24 interface=wg0 # WireGuard 피어 추가 (외부 클라이언트) # 클라이언트 퍼블릭키와 Allowed Address는 클라이언트 설정에 맞게 수정 /interface wireguard peers add interface=wg0 public-key="클라이언트퍼블릭키" allowed-address=10.10.10.2/32 # 방화벽 규칙 (WireGuard 허용) /ip firewall filter add chain=input action=accept protocol=udp dst-port=51820 in-interface=WAN # 내부 특정 IP(192.168.1.44)로 포트포워딩 (예: TCP 3389 원격데스크톱) /ip firewall nat add chain=dstnat action=dst-nat protocol=tcp dst-port=3389 in-interface=wg0 to-addresses=192.168.1.44 to-ports=3389 # 기본 방화벽 규칙 /ip firewall filter add chain=input connection-state=established,related action=accept /ip firewall filter add chain=input connection-state=invalid action=drop /ip firewall filter add chain=input in-interface=WAN action=drop # 호스트네임 설정 /system identity set name="WG-Router" # 인터페이스 이름 변경 /interface ethernet set [find default-name=ether1] name=WAN /interface ethernet set [find default-name=ether2] name=LAN1 /interface ethernet set [find default-name=ether3] name=LAN2 /interface ethernet set [find default-name=ether4] name=LAN3 # LAN IP 주소 설정 /ip address add address=192.168.1.1/24 interface=LAN1 /ip address add address=192.168.1.1/24 interface=LAN2 /ip address add address=192.168.1.1/24 interface=LAN3 # DHCP 서버 설정 (LAN1 기준) /ip pool add name=dhcp_pool ranges=192.168.1.10-192.168.1.100 /ip dhcp-server add name=dhcp1 interface=LAN1 address-pool=dhcp_pool lease-time=1d /ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 dns-server=192.168.1.1 # DNS 설정 /ip dns set servers=8.8.8.8,1.1.1.1 allow-remote-requests=yes # NAT 설정 (LAN → WAN 인터넷 공유) /ip firewall nat add chain=srcnat out-interface=WAN action=masquerade # WireGuard 인터페이스 생성 /interface wireguard add name=wg0 listen-port=51820 private-key="서버프라이빗키" # WireGuard 서버 IP 설정 (VPN 전용 네트워크) /ip address add address=10.10.10.1/24 interface=wg0 # WireGuard 피어 추가 (외부 클라이언트) /interface wireguard peers add interface=wg0 public-key="클라이언트퍼블릭키" allowed-address=10.10.10.2/32 # 방화벽 규칙 (WireGuard 허용) /ip firewall filter add chain=input action=accept protocol=udp dst-port=51820 in-interface=WAN # 라우팅 설정: VPN 클라이언트가 내부 네트워크(192.168.1.0/24)에 접근 가능하도록 /ip route add dst-address=192.168.1.0/24 gateway=wg0 # 기본 방화벽 규칙 /ip firewall filter add chain=input connection-state=established,related action=accept /ip firewall filter add chain=input connection-state=invalid action=drop /ip firewall filter add chain=input in-interface=WAN action=drop /interface wireguard peers set [find public-key="클라이언트퍼블릭키"] allowed-address=10.10.10.2/32,192.168.1.0/24 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN1 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN2 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN3 /ip firewall nat add chain=srcnat out-interface=WAN action=masquerade # wg0 → LAN 트래픽은 NAT 불필요 # WireGuard 인터페이스 /interface wireguard add name=wg0 listen-port=51820 private-key="서버프라이빗키" /ip address add address=10.10.10.1/24 interface=wg0 # WireGuard 피어 (클라이언트) /interface wireguard peers add interface=wg0 public-key="클라이언트퍼블릭키" allowed-address=10.10.10.2/32,192.168.1.0/24 # 방화벽 규칙 (VPN → LAN 허용) /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN1 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN2 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN3 # WireGuard 포트 허용 /ip firewall filter add chain=input action=accept protocol=udp dst-port=51820 in-interface=WAN # WireGuard 인터페이스 /interface wireguard add name=wg0 listen-port=51820 private-key="서버프라이빗키" /ip address add address=10.10.10.1/24 interface=wg0 # WireGuard 피어 (클라이언트) /interface wireguard peers add interface=wg0 public-key="클라이언트퍼블릭키" allowed-address=10.10.10.2/32,192.168.1.0/24 # 방화벽 규칙 (VPN → LAN 허용) /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN1 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN2 /ip firewall filter add chain=forward action=accept in-interface=wg0 out-interface=LAN3 # WireGuard 포트 허용 /ip firewall filter add chain=input action=accept protocol=udp dst-port=51820 in-interface=WAN