1. iptables ...
뭐.. 방화벽... 입니다.... 풋...
대부분 아실거라고 생각하지만 중요한 점은 규칙을 정할 때의 순서!!! 입니다.
IF 모든 패킷을 거부하는 규칙이 가장 먼저 나온다면 그 이후의 규칙은 무시가 되어버립니다.
그리하여... 허용되는 규칙이 먼저 나오고 나중에 거부하는 규칙을 정의해야 합니다. ^^
2. iptable 명령
[root@bridge ~]# iptables -L // 현재 정의된 규칙 보여주기
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT ipv6-crypt-- anywhere anywhere
ACCEPT ipv6-auth-- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
[root@bridge ~]# iptables -F // 규칙 초기화
[root@bridge ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (0 references)
target prot opt source destination
[root@bridge ~]# iptables -A INPUT -p icmp -s 127.0.0.1 -j DROP
// 출발지가 127.0.0.1인 (-s 127.0.0.1) icmp 프로토콜 (-p icmp) 패킷을 거부(-j DROP) 하는
규칙을 추가(-A) 합니다.
[root@bridge ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP icmp -- bridge anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (0 references)
target prot opt source destination
[root@bridge ~]# ping 127.0.0.1 // ping 이 먹히질 않죠 ㅋ
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
--- 127.0.0.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms
[root@bridge ~]# iptables -A INPUT -p tcp --dport 23 -j DROP
// 목적지 포트가 23번(--dport 23)이고 tcp 프로토콜 (-p tcp)인 패킷을 거부(-j DROP)하는
규칙을 추가(-A) 합니다.
[root@bridge ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP icmp -- bridge anywhere
DROP tcp -- anywhere anywhere tcp dpt:telnet
// 자동으로 23번포트 telnet 으로 설정
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (0 references)
target prot opt source destination
[root@bridge ~]# iptables -D INPUT 1
//INPUT 란의 2번째 (0,1,2...) 설정을 삭제 하는 기능입니다.
이 정도가 기본입니다. 뭐 옵션 하나씩 하는 것보다 이렇게 써 놓으면 보기 더 편한것 같습니다. ㅎ
아닌가??? 풋...
대략 다시 설명하자면
-A 새로운 규칙 입력
-D 규칙 삭제
-F 모든 규칙 삭제
-L 규칙 보기
-s 출발지 주소
-d 목적지 주소
--sport 출발지 포트 번호
--dport 목적지 포트 번호
-p 프로토콜
-j 규칙 설정
입니다. ^^
'Linux' 카테고리의 다른 글
리눅스 부팅 과정 (0) | 2009.06.14 |
---|---|
브릿지 방화벽 구축하기!!!!!!!! (0) | 2009.06.14 |
at cron (0) | 2009.06.14 |
chkconfig (0) | 2009.06.11 |
Xinetd (eXtended inetd) (0) | 2009.06.11 |