우분투 18.04에서 iptables 다시로드 / 다시 시작 Red Hat과 함께 사용하기 전에 Ubuntu 18.04의

Centos 7 및 Red Hat과 함께 사용하기 전에 Ubuntu 18.04의 iptables에 문제가 있으며 간단히

systemctl restart iptables

그러나 우분투에서는 작동하지 않습니다. 나는 아래에서 iptable을 찾을 수 없었다 init.d.

우분투 18.04에서 어떻게 다시 시작하거나 다시로드 할 수 있습니까?



답변

Ubuntu 18.04의 RedHat / Fedora와 유사한 방식으로 Ubuntu 방화벽이 작동하려면 다음을 원할 것입니다.

sudo apt install iptables-persistent netfilter-persistent

그런 다음 /etc/iptables/rules.v[46]

유용 할 수있는 다른 명령 :

netfilter-persistent save
netfilter-persistent start

iptables-save  > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6

iptables-restore  < /etc/iptables/rules.v4
ip6tables-restore < /etc/iptables/rules.v6

systemctl stop    netfilter-persistent
systemctl start   netfilter-persistent
systemctl restart netfilter-persistent

두 패키지는 비슷하지만 약간 다른 기능을 제공합니다. 만 설치 iptables-persistent하면 systemd에서 올바른 처리를위한 서비스 정의 파일을 얻을 수 없습니다./lib/systemd/system/netfilter-persistent.service

만 설치 netfilter-persistent하면 README에 따라 부팅시 규칙이 올바르게 적용되지 않습니다.

netfilter-persistent and its plugins
------------------------------------

netfilter-persistent does no work on its own. You need the accompanying
plugins (for example, iptables-persistent) to load and save filter rules.

However, commands are run from netfilter-persistent. For example, to save
all filter rules:

   netfilter-persistent save

or to load them:

   netfilter-persistent start

For more details, see `man netfilter-persistent`.

The system service will try to load rules at startup if enabled, but by
default it will not flush rules at shutdown. This behaviour can be changed
by editing /etc/default/netfilter-persistent.


답변

최신 배포에서는 일반적으로 방화벽을 구성하고 관리하기위한 프런트 엔드가 있습니다. 가장 인기있는 요즘입니다 ufwfirewalld아마 shorewall. 그 프론트 엔드는에 규칙을 추가하는데주의를 기울여야 iptables하고, iptables프론트 엔드는 당신이 수행 한 변경 데리러하지 않으므로, 스크립트는 건너 뛰어야 말을 생략 또는 더 나은 될 수 있습니다 iptables직접 명령을.

Ubuntu 18.04의 경우 설치되었지만 비활성화 된 firewalld기본값이 된 것 같습니다 ufw.

root@localhost:~# firewall-cmd --state
running
root@localhost:~# ufw status
Status: inactive

따라서 자체 iptables준수 규칙을 만드는 대신 이러한 프런트 엔드를 사용하여 방화벽 구성을 만들어야합니다.

나는 잘 ufw모르지만 당신은 여기 askubuntu 또는 인터넷의 다른 곳에서 정보를 찾을 것입니다.
firewalldGUI ( firewall-config) 및 명령 줄 도구와 함께 제공됩니다 firewall-cmd.
현재 firewalld규칙을 적용하지 않고 ( 영구적 ) 규칙을 추가 하고 방화벽을 다시로드 한 후에 만 ​​적용 할 수 있습니다. 또는 런타임 구성에 추가하고 테스트 한 후 영구 구성에 추가 할 수 있습니다.
예를 들어 새로 추가 된 영구 구성을 실행 규칙에 다시로드하려면 다음과 같이 명령을 입력하거나 GUI에서 해당 클릭을 수행해야합니다.

firewall-cmd --reload

구역체인 개념을 firewalld따르기 때문에 언뜻보기에는 조금 더 복잡해 보일 수 있습니다 . 그러나 그것은 NetworkManager 와 잘 통합되고 GUI를 제공합니다 .
그것에 익숙해지기위한 좋은 출발점이 여기 있습니다 .


답변

패키지 내용은 다음을 사용하여 확인할 수 있습니다.

dpkg -L iptables-persistent

그리고 다음 명령이 올바른 것을 알 수 있습니다.

/etc/init.d/netfilter-persistent restart


답변

Ubuntu 1804에서 지속성을 얻으려면 iptables-save> /etc/iptables/rules.v4 명령을 사용하십시오.

또는 iptables 행을 파일에 직접 추가하십시오. /etc/iptables/rules.v4


답변

데비안 / 우분투에는 iptables에 대한 init 스크립트가 없습니다 (페도라 / RHEL / Centos와 달리)

서버를 재부팅 할 때 e를 작성하여 스크립트를 작성하거나 iptables가 재설정되는 것을 볼 수 있습니다

UFW https://help.ubuntu.com/community/UFW를 대신 사용 하십시오

또는 방화벽

우분투 16.04에서 iptables를 어떻게 방화벽으로 대체 할 수 있습니까?


답변