기본 Linux Iptables 방화벽 문제

기본 Linux Iptables 방화벽 문제

Iptables가 설치된 호스트의 터미널에 이러한 명령을 입력하면 인터넷 접속이 가능한 무선 네트워크에 연결된 후 웹 페이지가 로드되지 않습니다.

간단한 일인 것은 알지만 무엇인지는 모르겠습니다.

sudo iptables --policy INPUT DROP
sudo iptables --policy OUTPUT DROP
sudo iptables --policy FORWARD DROP

sudo iptables -A OUTPUT -j ACCEPT -p tcp --destination-port 53

sudo iptables -A OUTPUT -j ACCEPT -p tcp --destination-port 80

sudo iptables -A OUTPUT -j ACCEPT -p tcp --destination-port 443

sudo iptables -A OUTPUT -j ACCEPT -p udp --destination-port 53


sudo /sbin/iptables-save

이전 명령 다음에 나열된 구성은 다음과 같습니다.

user@debian:~$ sudo iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain


user@debian:~$ sudo iptables -L -v
Chain INPUT (policy DROP 1095 packets, 131K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy DROP 33 packets, 2574 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:domain
    8   480 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:http
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:https
 1072 70910 ACCEPT     udp  --  any    any     anywhere             anywhere             udp dpt:domain

이 경우에는 기본 DNS, HTTP 및 HTTPS를 찾고 있습니다. 뭐가 문제 야?

답변1

sudo iptables --policy INPUT DROP

이는 기본적으로 들어오는 모든 트래픽을 삭제합니다. 이 정책에 예외를 적용하는 규칙이 없습니다. 즉, 나가는 트래픽을 허용하는 OUTPUT 규칙만 있습니다. 일반적으로 다음과 같이 내부에서 설정된 입력 일치 연결을 허용하는 규칙이 하나 이상 있습니다.

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

관련 정보