아래와 비슷한 질문을 많이 시도했는데, 제 경우에는 VM을 사용했습니다.데비안 운영 체제존재하다가상 상자:
- https://serverfault.com/questions/129086/how-to-start-stop-iptables-on-ubuntu
- Debian 시스템을 다시 시작한 후 iptables 규칙이 사라지는 이유는 무엇입니까?
- https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules
- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-iptables-on-ubuntu-14-04
iptables
다음 명령을 사용하여 규칙을 새로 고치 려고 했습니다 .
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
다음은 다음 명령입니다.
sudo iptables -t nat -F
sudo iptables -t mangle -F
sudo iptables -F
sudo iptables -X
나는 이전에 시도했습니다:
iptables-save > /etc/iptables/rules.v4
iptables-save > /etc/iptables/rules.v6
머신을 재부팅했을 때 다시 이전 규칙으로 돌아갔습니다. 여전히 동일한 규칙이 있습니다. 을(를 ) 사용해 보았 iptables-save
더니 이러한 메시지가 표시되었습니다.
# Generated by iptables-save v1.4.21 on Wed Mar 28 03:44:14 2018
*nat
:PREROUTING ACCEPT [127:23299]
:INPUT ACCEPT [14:1996]
:OUTPUT ACCEPT [32:1947]
:POSTROUTING ACCEPT [32:1947]
:OUTPUT_direct - [0:0]
:POSTROUTING_ZONES - [0:0]
:POSTROUTING_ZONES_SOURCE - [0:0]
:POSTROUTING_direct - [0:0]
:POST_public - [0:0]
:POST_public_allow - [0:0]
:POST_public_deny - [0:0]
:POST_public_log - [0:0]
:PREROUTING_ZONES - [0:0]
:PREROUTING_ZONES_SOURCE - [0:0]
:PREROUTING_direct - [0:0]
:PRE_public - [0:0]
:PRE_public_allow - [0:0]
:PRE_public_deny - [0:0]
:PRE_public_log - [0:0]
-A PREROUTING -j PREROUTING_direct
-A PREROUTING -j PREROUTING_ZONES_SOURCE
-A PREROUTING -j PREROUTING_ZONES
-A OUTPUT -j OUTPUT_direct
-A POSTROUTING -j POSTROUTING_direct
-A POSTROUTING -j POSTROUTING_ZONES_SOURCE
-A POSTROUTING -j POSTROUTING_ZONES
-A POSTROUTING_ZONES -g POST_public
-A POST_public -j POST_public_log
-A POST_public -j POST_public_deny
-A POST_public -j POST_public_allow
-A PREROUTING_ZONES -g PRE_public
-A PRE_public -j PRE_public_log
-A PRE_public -j PRE_public_deny
-A PRE_public -j PRE_public_allow
COMMIT
# Completed on Wed Mar 28 03:44:14 2018
# Generated by iptables-save v1.4.21 on Wed Mar 28 03:44:14 2018
*mangle
:PREROUTING ACCEPT [4925:1051078]
:INPUT ACCEPT [4925:1051078]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4791:1080206]
:POSTROUTING ACCEPT [4791:1080206]
:FORWARD_direct - [0:0]
:INPUT_direct - [0:0]
:OUTPUT_direct - [0:0]
:POSTROUTING_direct - [0:0]
:PREROUTING_ZONES - [0:0]
:PREROUTING_ZONES_SOURCE - [0:0]
:PREROUTING_direct - [0:0]
:PRE_public - [0:0]
:PRE_public_allow - [0:0]
:PRE_public_deny - [0:0]
:PRE_public_log - [0:0]
-A PREROUTING -j PREROUTING_direct
-A PREROUTING -j PREROUTING_ZONES_SOURCE
-A PREROUTING -j PREROUTING_ZONES
-A INPUT -j INPUT_direct
-A FORWARD -j FORWARD_direct
-A OUTPUT -j OUTPUT_direct
-A POSTROUTING -j POSTROUTING_direct
-A PREROUTING_ZONES -g PRE_public
-A PRE_public -j PRE_public_log
-A PRE_public -j PRE_public_deny
-A PRE_public -j PRE_public_allow
COMMIT
# Completed on Wed Mar 28 03:44:14 2018
# Generated by iptables-save v1.4.21 on Wed Mar 28 03:44:14 2018
*security
:INPUT ACCEPT [4826:1030935]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4814:1084121]
:FORWARD_direct - [0:0]
:INPUT_direct - [0:0]
:OUTPUT_direct - [0:0]
-A INPUT -j INPUT_direct
-A FORWARD -j FORWARD_direct
-A OUTPUT -j OUTPUT_direct
COMMIT
# Completed on Wed Mar 28 03:44:14 2018
# Generated by iptables-save v1.4.21 on Wed Mar 28 03:44:14 2018
*raw
:PREROUTING ACCEPT [4949:1054264]
:OUTPUT ACCEPT [4815:1084545]
:OUTPUT_direct - [0:0]
:PREROUTING_direct - [0:0]
-A PREROUTING -j PREROUTING_direct
-A OUTPUT -j OUTPUT_direct
COMMIT
# Completed on Wed Mar 28 03:44:14 2018
# Generated by iptables-save v1.4.21 on Wed Mar 28 03:44:14 2018
*filter
:INPUT ACCEPT [2653:591941]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2649:609004]
COMMIT
# Completed on Wed Mar 28 03:44:14 2018
제가 원하는 것은 아래와 같은 규칙입니다. 내 명령을 다음과 같이 설정했습니다 rules.v4
.
# Generated by iptables-save v1.4.21 on Tue Mar 27 02:48:59 2018
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
# Completed on Tue Mar 27 02:48:59 2018
하지만 시스템을 다시 시작할 때마다 항상 이전 규칙이 표시됩니다.
내 구성에 어떤 문제가 있을 수 있나요? 내가 뭐 놓친 거 없니?
제거하고 다시 설치해 보았 iptables-persistent
으나 여전히 동일한 규칙이 나타납니다...
답변1
다음 명령을 사용하여 IPV6 테이블을 저장합니다.
ip6tables-save > /etc/iptables/rules.v6
IPV6 테이블을 복원하려면 다음을 사용하십시오.
ip6tables-restore < /etc/iptables/rules.v6
이 명령은 IPV4 테이블을 관리하는 데 iptables-save
에만 사용됩니다.iptables-restore
바라보다 man iptables-save
:
iptables-save — dump iptables rules to stdout ip6tables-save — dump iptables rules to stdout
그리고man iptables-restore
iptables-restore — Restore IP Tables ip6tables-restore — Restore IPv6 Tables