nugawiki

./categories/os

Synology Docker 클라이언트 IP (iptables)

업데이트 2026-07-21 조회수

원인: Synology Docker 패키지에 일반 Docker용 iptables NAT 규칙이 빠져 클라이언트 IP가 안 보임.

해결

제어판 → 작업 스케줄러 → 트리거된 작업 → 부팅 시 / 사용자 root

#!/bin/bash
currentAttempt=0
totalAttempts=10
delay=15
while [ $currentAttempt -lt $totalAttempts ]; do
  currentAttempt=$((currentAttempt + 1))
  echo "Attempt $currentAttempt of $totalAttempts..."
  result=$(iptables-save)
  if [[ $result =~ "-A DOCKER -i docker0 -j RETURN" ]]; then
    echo "Docker rules found! Modifying..."
    iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
    iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER
    echo "Done!"
    break
  fi
  echo "Docker rules not found! Sleeping for $delay seconds..."
  sleep $delay
done

즉시 적용: 작업 스케줄러에서 Run.

참고: https://gist.github.com/pedrolamas/db809a2b9112166da4a2dbf8e3a72ae9

./comments