2008. 4. 2.

RHCE linux iptables

31. 기본적인 firewall 정책을 실행하기 위해 iptables 사용하기, Red Hat Linux에서의 User

Private Group scheme 이해

# iptables -A INPUT -p TCP -s xxx.xxx.xxx.0/24 --destination-port 3306 -j ACCEPT

이제 xxx.xxx.xxx.0 ~ 255 까지의 IP 대에서 접근이 가능합니다.
-A : 새로운 rule 을 추가하는 옵션 (INPUT, FORWARD, OUTPUT)
-p : 사용할 프로토콜을 지정 (TCP, UDP)
-s : 사용할 ip 주소를 지정
--destination-port : 사용할 포트를 지정
-j : 패킷처리방법을 지정(ACCEPT, DROP, REJECT)

추가했던 chain rule 을 제거하는 방법
# iptables -D INPUT -p TCP -s xxx.xxx.xxx.0/24 --destination-port 3306 -j ACCEPT

rule delete

- iptables 일부 포트만 열어주는 방법

IPTABLES 현재 상황 보기
# iptables -L

모든것을 DROP 시키는 방법
# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# iptables -P FORWARD DROP

허용하는 설정
# iptables -A INPUT -p TCP --destination-port 23 -j ACCEPT
# iptables -A OUTPUT -p TCP --source-port 23 -j ACCEPT

허용하는 설정
# iptables -A INPUT -p TCP --destination-port 21 -j ACCEPT
# iptables -A OUTPUT -p TCP --source-port 21 -j ACCEPT

허용하는 설정
# iptables -A INPUT -p ICMP --icmp-type 8 -j ACCEPT
# iptables -A OUTPUT -p ICMP -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A OUTPUT -p ICMP --icmp-type 8 -j ACCEPT
# iptables -A INPUT -p ICMP -m state --state ESTABLISHED,RELATED -j ACCEPT

허용하는 설정
# iptables -A OUTPUT -p UDP --destination-port 53 -j ACCEPT
# iptables -A INPUT -p UDP --source-port 53 -j ACCEPT
# iptables -A OUTPUT -p TCP --destination-port 53 -j ACCEPT
# iptables -A INPUT -p TCP --source-port 53 -m state --state ESTABLISHED,RELATED -j

ACCEPT

허용하는 설정
# iptables -A INPUT -p TCP --destination-port 80 -j ACCEPT
# iptables -A OUTPUT -p TCP --source-port 80 -j ACCEPT


ex)
# DNS: Full Server (53)
# Sever/Client to Server query or response
/sbin/iptables -A INPUT --in-interface eth0 -p udp --source-port 1024: --destination $MY_IP --destination-port 53 -j ACCEPT
/sbin/iptables -A O

댓글 없음: