본문 바로가기

Computer Engineering/LINUX

LINUX#2 - 방화벽

요즘은 특히 보안이 중요해 지고 있다. 왠만한 사이트들도 해킹을 당할 가능성이 크다. 그런 사람들이 마음먹고 공격하려고 하면 뚫릴 수 있다고 본다. 해킹을 당하지 않는 방법은 인터넷을 연결하지 않는 것이다. ㅋㅋㅋ

리눅스에서 기본적으로 방화벽을 설치할 수 있다. iptable 을 이용해보자. 간단하게 말하면 PORT 를 막는 것이다. 완전히 다 닫는 것은 특정 포트를 주석처리 하면 되지만, 그 PORT는 어떤 클라이언트라고 해도 문제가 있다. PORT 를 누구한테는 열어두고 누구에게는 닫아놓고 ... PORT를 열고 닫는 것이다.

커맨드는 쉽게 외워지는 것이 아니어서 형식이 어떤지 보고 하는 것이 좋을 것이다.

SYNOPSIS 
      iptables [-t table] -A chain rule-specification [options] ; 선택한 chain 맨 아래쪽에 한개의상의 rule 추가 
      iptables [-t table] -I chain [rulenum] rule-specification [options] ; 선택된 chain에 한개 이상의 룰 추가 
      iptables [-t table] -R chain rulenum rule-specification [options] ; 선택된 chain 으로 부터 rule 변경 
      iptables [-t table] -D chain rulenum [options]  ;  선택된 chain으로 부터 한개의상의 rule 삭제 
      iptables [-t table] -[LFZ] [chain] [options] 
      iptables [-t table] -N chain    ; chain 생성 
      iptables [-t table] -X [chain]  ; chain 삭제 
      iptables [-t table] -P chain target [options]  ;  target 에 대한 chain 정책 설정 
      iptables [-t table] -E old-chain-name new-chain-name ; chain 이름 변경 
iptables [-t table ] -F chain ; 선택된 chain 삭제, -F 옵션뒤에 chain 을 명시하지 않으면 모든 체인 삭제. 
                                                  (This is equivalent to deleting all the rules one by  one.)        


이런 것들이 있다.

SERVER[/root]# 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

=> 지금과 같이 아무것도 안들어 있다는 것은 차단하는 것이 아무것도 없다는 것이다.

SERVER[/root]# iptables -X RH-Firewall-1-INPUT          => 마지막에 있던 RH~ 는 삭제해 줄 수 있다.
SERVER[/root]# 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

=> 하지만 위의 3가지의 기본 chain은 삭제할 수 없다.
안에는 규칙(Rule)이 들어 가는 것이다.

SERVER[/]# service iptables restart
방화벽 규칙을 삭제하는 중:                                 [  OK  ]
chains를 ACCEPT 규칙으로 설정함: filter                    [  OK  ]
iptables 모듈을 제거하는 중:                               [  OK  ]
iptables 방화벽 규칙들을 적용하는 중:                      [  OK  ]
추가 iptables 모듈을 읽어오는 중: ip_conntrack_netbios_ns i[  OK  ]ack_ftp

 => 디폴트 값을 불러오기

DROP REJECT 차이 메세지를 보여주고 안보여주는 것. 서버측에서는 DROP이 조금 더 낫다. DROP은 메세지 조차 안보여준다. REJECT는 알려는 것이다.
 



'Computer Engineering > LINUX' 카테고리의 다른 글

LINUX#2 - 다시 한 번 시작해 봅시다 ^^  (0) 2011.10.15
LINUX#2 - IDS  (0) 2011.08.01
LINUX#2 - Apache(2)  (0) 2011.07.28
LINUX#2 - Apache  (0) 2011.07.27
LINUX#2 - Logrotate  (0) 2011.07.26