posted by 귀염둥이채원 2018. 11. 27. 08:13

iptables 의 명령어에 대해 알아보겠습니다.

 

-A : append a Rule (--append) 정책수립

-D : delete a Rule (---delete) 정책삭제

-C : test packets ( --check)

-R : replace a new Rule(--replace)

-I : insert a rUle(--insert)

-L : show the Rules in the chain (--list) 정책목록확인

-F : delete all Rules (-flush) 모든정책삭제

-Z : make a new chain (--zero)

-N : make a new chain (--new)

-X : delete a new chain (--delete-chain)

-P : change a basic Rules(--policy)

 

제가 옆에 설명달아논것들을 보통 많이쓴답니다.

 

-s : source address (보내는 사람주소 ip)

-d : destination address (받는사람주소ip)

-i : input interface (INPUT ,FORWARD chain에서 사용 가능) -데이터가 들어오는길

-p : protocol name -통신의 언어

-o : output interface (OUTPUT chain 에서 사용 가능) -데이터가 나가는길

-f : 분절

-j : command 이후에 붙이는 옵션

- ACCEPT패킷을 허용

- DROP : 패킷을 허용하지 않으며, 허용하지 안흔ㄴ 메시지를 보내지 않음

 

ICMP방어!

 

ICMP: 목적지의 가용성 확인을 위한 ping메시지에 사용되는 프로토콜

 

예)

 

iptables -A INPUT -p icmp -j DROP

 

해석 -> icmp로 나에게 들어오는것이 있으면 DROP시키겠다.

 

iptables -A INPUT -p tcp --dpotr 7070 -j DROP

 

해석 -> INPUT체인에 protocol은 TCP 이고 destination port는 7070인 패킷을 DROP한다.

 

iptables -A OUTPUT -p udp --sport 6060 -j DROP

 

해석-> OUTPUT 체인에 protocol은 UDP이고 source port는 6060인 패킷을 DROP한다.