apt install -y iptables-persistent netfilter-persistent net-tools
방화벽 설정을 위해 위 서비스들을 먼저 설치해준다
기본 설정
iptables [option]
ex)
iptables -A OUTPUT -d 8.8.8.8 -p icmp -j DROP # 8.8.8.8로 나가는 ping 차단
iptables -A INPUT -p tcp --dport 23 -j DROP # telnet 접속 차단
iptables -N LOG_DROP # LOG_DROP 이라는 chain 추가
iptables -A LOG_DROP -j LOG --log-prefix "Mylog" # LOG_DROP chain에 LOG 정책 추가 LOG에 Mylog라는 메세지 추가
iptables -A LOG_DROP -p icmp -d 8.8.8.8 -j DROP # 8.8.8.8로 ping 차단과 같으나 LOG_DROP에 추가
iptables -nvL # 방화벽 정책 목록 자세히
iptables -A OUTPUT -j LOG_DROP # LOG_DROP에 있는 정책을 OUTPUT에 적용
예시를 적용해보고 /var/log/kern.log 에 로그가 올라오는지 ping 이 drop되는지 확인
Fail2ban으로 ssh 차단
apt install -y fail2ban openssh-server
ssh 서버와 fail2ban을 설치해준다
ssh로 접속해서 비밀번호를 계속 틀리면서 밴을 당하는걸 확인
만들지 않은 f2b-sshd chain이 생긴걸 확인할수 있다
'Linux' 카테고리의 다른 글
Ubuntu Webhard (0) | 2023.07.31 |
---|---|
Ubuntu Web (0) | 2023.07.28 |
Ubuntu DHCP (0) | 2023.07.28 |
Ubuntu DNS (0) | 2023.07.28 |
Ubuntu samba (0) | 2023.07.27 |