iptables 포트포워딩을 통하여 (외부IP주소:포트)로 (내부IP주소:포트)에 접근하려고 합니다.

Harvey Moon@Google의 이미지

안녕하세요.

iptables을 이용한 포트포워딩이 잘 안돼서 조언을 구합니다.

1) 라즈비안OS에 도커 컨테이너를 띄우고 nginx로 웹서버를 구축하였습니다.

2) IP주소에 포트 설정까지 하였습니다. (내부 IP주소: 222.22.2.2:8888)

3) 공유기를 통한 내부망뿐만 아니라 외부망 어디서든지 접속가능하게 하려는 목적으로 포트포워딩을 하였습니다

4) KT통신사가 제공하는 공유기 설정페이지에서 포트포워딩을 설정하고,
외부 IP주소로 접속해보고, 내부 IP주소로도 접속해보니 잘 됩니다.
예) 111.111.11.111:8888 (외부 IP주소) -> 222.22.2.2:8888 (내부 IP주소)

5) 다음으로 iptables를 이용하여 포트포워딩을 시도해보았습니다.
검색을 통한 여러가지 방법을 다 적용해봤지만 모두 되지 않았습니다.
방법이 잘못된건지 통신사에게 막아놓은 것인지 아니면 원래 안되는 것인지 알지 못하여 글을 올리게 되었습니다

** 제가 적용해 보았던 소스들도 첨부하니 참조 부탁드립니다.

iptables -t nat -A PREROUTING -i wlan0 -p tcp -m tcp --dport 8888 -j DNAT --to-destination 222.22.2.2:8888
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

iptables -t nat -A PREROUTING -p tcp --dport 8888 -j DNAT --to-destination 222.22.2.2:8888
iptables -A INPUT -p tcp --dport 8888 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8888 -j ACCEPT

iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -i wlan0 --dport 8888 -j DNAT --to 222.22.2.2:8888

ptables -A PREROUTING -t nat -p tcp -d 111.111.11.111 --dport 8888 -j DNAT --to 222.22.2.2:8888
iptables -A FORWARD -p tcp --dport 8888 -d 222.22.2.2 -j ACCEPT

iptables -I INPUT 1 -p tcp --dport 8888 -j ACCEPT
iptables -I OUTPUT 1 -p tcp --dport 8888 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 8888 -j REDIRECT --to-port 8888

invoke-rc.d netfilter-persistent save
invoke-rc.d netfilter-persistent reload

Harvey Moon@Google의 이미지

이해를 돕기 위해 파일을 첨부하였습니다

댓글 첨부 파일: 

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.