iptables 에서 포트 열어주기.

ggamzzak의 이미지

데비안 리눅스(커널2.6.16)를 사용중이고 Apache2+php5+mysql5 를 사용중입니다.
회사에 서버 관리자가 현재 부재중이라 제가 대충 관리하고 있는 실정입니다.

회사 서버에 jsp 환경 구축을 위해 톰캣을 설치했는데 기본 포트가 8180 입니다.
그런데 포트가 닫혀있어서 iptables 에서 포트를 추가해야 할거 같은데

iptables -A INPUT -p TCP --dport 8180 -j ACCEPT
iptables -A OUTPUT -p TCP --sport 8180 -j ACCEPT

제가 서버 관리자가 아니라 사이트 검색 좀 하고 위와 같이 입력했더니 http 400 error 가 납니다.
8180 포트를 서버의 iptables 에 맞게 명령어를 어찌 써야 할지 알려주시면 감사하겠습니다.
(제가 찾아보면서 해야 하는게 마땅하나, 시간이 많이 부족하여 이렇게나마 글을 올립니다.)

아래는 수정해야 할 서버의 iptables -L 내용입니다.
(사정상 도메인과 아이피는 살짝 임의로 고쳤습니다.)

--------------------------------------------------------------------------------------
tom:/etc/tomcat5.5# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
DROP all -- anywhere anywhere state INVALID
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
syn-flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN
DROP tcp -- anywhere anywhere tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
DROP all -- 10.0.0.0/8 anywhere
DROP all -- 172.16.0.0/12 anywhere
DROP all -- 192.168.0.0/16 anywhere
DROP all -- BASE-ADDRESS.MCAST.NET/4 anywhere
DROP all -- 240.0.0.0/4 anywhere
DROP all -- anywhere 127.0.0.0/8
DROP all -- anywhere 211.222.111.255
icmp-in icmp -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:32 flags:FIN,SYN,RST,ACK/SYN limit: avg 10/sec burst 20
LOG tcp -- anywhere anywhere tcp dpt:32 flags:FIN,SYN,RST,ACK/SYN limit: avg 20/min burst 5 LOG level warning prefix `SYN-FLOOD: '
ACCEPT tcp -- anywhere anywhere tcp dpt:32 flags:!FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp spt:32 state ESTABLISHED
ACCEPT udp -- kns.kornet.net anywhere udp spt:domain state ESTABLISHED
ACCEPT udp -- kns2.kornet.net anywhere udp spt:domain state ESTABLISHED
ACCEPT udp -- ns.lgdacom.net anywhere udp spt:domain state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:www flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:ldap flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:https flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:rtsp flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:1220 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:svn flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:rsync flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:31 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpts:40000:50000 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:www flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:imap2 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:https flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:953 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:5004 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:10024 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:10025 flags:FIN,SYN,RST,ACK/SYN
ACCEPT tcp -- localhost.localdomain anywhere tcp dpt:24471 flags:FIN,SYN,RST,ACK/SYN

Chain FORWARD (policy DROP)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
icmp-out icmp -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere udp spts:32769:65535 dpts:33434:33523 state NEW

Chain icmp-in (1 references)
target prot opt source destination
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp echo-reply
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp destination-unreachable
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp source-quench
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp time-exceeded
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp parameter-problem
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp timestamp-reply
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp type 16
RETURN icmp -- anywhere tom.aaaaaaaa.in icmp address-mask-reply
DROP all -- anywhere anywhere

Chain icmp-out (1 references)
target prot opt source destination
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp source-quench
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp echo-request
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp parameter-problem
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp timestamp-request
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp type 15
RETURN icmp -- tom.aaaaaaaa.in anywhere icmp address-mask-request
DROP all -- anywhere anywhere

Chain syn-flood (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere limit: avg 5/sec burst 20
LOG all -- anywhere anywhere limit: avg 30/min burst 5 LOG level warning prefix `SYN-FLOOD: '
DROP all -- anywhere anywhere
--------------------------------------------------------------------------------

염치 불구하고 답변 부탁드리겠습니다 (__

eltm6969의 이미지

http://community.365managed.com/pdf_magazine/3818

아파치 + 톰캣 연동이겠죠?.....

400에러라............"요청 실패"로 기억하고 있는데 맞는진 확인 해봐야 겠구요......

아마도......방화벽 문제가 아닌......전혀 엉뚱한 부분의 문제 일 소지가 있네요....

무슨말이냐면.....아파치에 톰캣 모듈을 심은 형태의 시스템이라면

아파치에 심어진 톰캣 모듈이 톰캣을 찾는 호스트는 localhost(127.0.0.1)일 겁니다.. 통상적으로....

그런데, 정말 희박한 경우로서,, 몇몇 시스템에 이 localhost에 대한 IP(127.0.0.1)이 정의 되어 있지 않는경우,

문제가 생깁니다.. 이런 경우, 원인을 알고 나면 허탈하죠...

저도 확신은 못하나, 이부분도 체크 해보시길 바랍니다.

/etc/hosts 파일에 127.0.0.1에 대해 localhost 로 제대로 정의되어 있는지..........

아무튼 장담은 못하나, 400에러라길래 드리는 의견입니다.. 방화벽에서 DROP된다면, 어떤 응답도 없겠다...라는 생각에.......

monovision의 이미지

먼저 iptables 를 초기화시키고 한 번 해보세요.

iptables 를 내린 상태에서 잘 된다면...... 아래의 커맨드를 실행시켜 보시구요...

1.
iptables -I INPUT 5 -p tcp --dport 8180 -m state --state NEW -j ACCEPT
or
iptables -I INPUT -p tcp --dport 8180 -j ACCEPT

2.
iptables -I INPUT -p tcp --sport 8180 -j ACCEPT

iptables 를 내린 상태에서도 400 error 가 뜬다면.... 톰캣 설정에 문제가 있는거겠죵...

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.