iptables
서버관리자 입장
snort 공격에 대해 snort 룰을 사전에정의했다면 탐지가 가능하다.
추가 패턴 옵션 : threshold
세부 옵션 : IP 발생 구조 ---- track by_src 출발지 기준
track by_dst 도착지 기준
로그 발생 타입 -- type threshold : 패킷 발생량 기준
type limit : 임계 시간
type both : IP
패킷 발생 카운트 - count 5
임계 시간 - seconds 2
외부 ---> 인터페이스 ---> snort
---> iptables : firewall / ufw
iptables 000> 탐지 가능 ---> LOG를 남겨라!
현재 상태 값 iptables -L
LOG all -- anywhere anywhere LOG level warning prefix "LOG TEST: "
iptables에 룰을 추가 (append) : -A
삭제 (delete) : -D
기본 로그 ---> level 4
Emerg 0
Alert 1
Crit 2
Error 3
Warning 4
Notice 5
Info 6
Debug 7
iptables -A INPUT -p tcp --dport 80 -j LOG --log-prefix "HTTP Log"
LOG tcp -- anywhere anywhere tcp dpt:http LOG level warning prefix "HTTP Log"
level warning : 기본값
기본 로그 파일 : /var/log/kern.log ---> 없는 경우 ---> /var/log/messages
rsyslogd
vim /etc/rsyslog.conf
#*.info;mail.none;authpriv.none;cron.none /var/log/messages
# IPtables Test Log
:msg,contains,"[HTTP Log]" /var/log/iptables_test.log
systemctl restart rsyslog
동작 : cd /var/log/
ls
iptables_test.log ---> 파일이 생성되어 있음을 확인
[root@localhost log]# firewall-cmd --add-service=http --permanent
success
[root@localhost log]# firewall-cmd --reload
success
[root@localhost log]#
iptables와 firewalld의 관계 : 같은 놈이다.
iptables에서 발생되는 Log정보는 시스템에 전달 된다.
시스템의 로그를 남기는 서비스 : rsyslog
[root@localhost httpd]# firewall-cmd
usage: see firewall-cmd man page
No option specified.
[root@localhost httpd]# firewall-cmd --state
not running
[root@localhost httpd]# systemctl restart firewalld
[root@localhost httpd]# firewall-cmd --state
running
[root@localhost httpd]# firewall-cmd --reload
success
[root@localhost httpd]# firewall-cmd --add-port=21/tcp --permanent
success
[root@localhost httpd]# firewall-cmd --reload
success
[root@localhost httpd]# iptables -L
add -- Open
remove -- Close
iptables에서 발생되는 Log정보는 시스템에 전달된다.
시스템의 로그를 남기는 서비스 : rsyslog
모든 Scan 차단
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
Xmas Scan 차단
iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
iptables -I INPUT -p tcp --tcp-flags FIN,PSH,URG FIN,PSH,URG -j LOG --log-prefix "[Xmas Scan Detection] "
NULL Scan iptables
iptables -I INPUT -p tcp --tcp-flags ALL NONE -j LOG --log-prefix "[Null Scan Detection]"
tcp wrapper : /etc/hosts.deny(차단), /etc/hosts.allow(허용)