iptables 에서 포트 열어주기.
데비안 리눅스(커널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
--------------------------------------------------------------------------------
염치 불구하고 답변 부탁드리겠습니다 (__
iptables 관련 문서 입니다. 도움이 되실거 같네요.
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된다면, 어떤 응답도 없겠다...라는 생각에.......
먼저 iptables 를
먼저 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 가 뜬다면.... 톰캣 설정에 문제가 있는거겠죵...
댓글 달기