Jak Mogę używać iptables na centos 7? [zamknięte]

Zamknięte. to pytanie nie spełnia wytycznych dotyczących przepełnienia stosu . Obecnie nie przyjmuje odpowiedzi.


Chcesz poprawić to pytanie? Update the pytanie więc to on-topic {[5] } dla przepełnienia stosu.

Zamknięte 1 rok temu .

Popraw to pytanie

Zainstalowałem CentOS 7 z minimalną konfiguracją (OS + dev tools). Próbuję otworzyć port 80 dla usługi httpd, ale coś jest nie tak z moją usługą iptables ... co z nim nie tak? Co? czy robię źle?

# ifconfig/sbin/service iptables save
bash: ifconfig/sbin/service: No such file or directory


# /sbin/service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

# sudo service iptables status
Redirecting to /bin/systemctl status  iptables.service
iptables.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

# /sbin/service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

# sudo service iptables start
Redirecting to /bin/systemctl start  iptables.service
Failed to issue method call: Unit iptables.service failed to load: No such file or directory.
Author: peterh - Reinstate Monica, 2014-07-15

9 answers

Z RHEL 7 / CentOS 7, firewalld został wprowadzony do zarządzania iptables. IMHO, firewalld bardziej nadaje się do stacji roboczych niż do środowisk serwerowych.

Możliwe jest powrót do bardziej klasycznej konfiguracji iptables. Po pierwsze, Zatrzymaj i zamaskuj usługę firewalld:

systemctl stop firewalld
systemctl mask firewalld

Następnie zainstaluj pakiet iptables-services:

yum install iptables-services

Włącz usługę w czasie rozruchu:

systemctl enable iptables

Zarządzanie serwisem

systemctl [stop|start|restart] iptables

Zapisywanie reguł zapory można wykonać jako follows:

service iptables save

Lub

/usr/libexec/iptables/iptables.init save
 336
Author: Sgaduuw,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-31 08:22:05

RHEL i CentOS 7 używają firewall-cmd zamiast iptables. Powinieneś użyć tego rodzaju polecenia:

# add ssh port as permanent opened port
firewall-cmd --zone=public --add-port=22/tcp --permanent

Następnie możesz przeładować reguły, aby mieć pewność, że wszystko jest w porządku

firewall-cmd --reload

Jest to lepsze niż używanie iptable-save, szczególnie jeśli planujesz używać kontenerów lxc lub Docker. Uruchomienie usługi docker doda kilka reguł, które wyświetli polecenie iptable-save. Jeśli zapiszesz wynik, będziesz miał wiele reguł, których nie należy zapisywać. Ponieważ kontenery docker mogą zmień ich adresy ip przy następnym restarcie.

Firewall-cmd z opcją permanent jest do tego lepszy.

Sprawdź "Man firewalld-cmd" lub sprawdź oficjalne dokumenty firewalld aby zobaczyć opcje. Istnieje wiele opcji, aby sprawdzić strefy, konfigurację, jak to działa... strona man jest naprawdę kompletna.

Zdecydowanie zalecam, aby nie używać iptables-service od Centos 7

 100
Author: Metal3d,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-11 16:25:22

Miałem problem, że restart nie uruchomi iptables.

This fixed it:

yum install iptables-services
systemctl mask firewalld
systemctl enable iptables
systemctl enable ip6tables
systemctl stop firewalld
systemctl start iptables
systemctl start ip6tables
 17
Author: par,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-06 20:01:58

Spróbuj wykonać następujące polecenie iptables-save.

 16
Author: João Chambel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-11 14:51:31

Zmodyfikowałem /etc/sysconfig/ip6tables-config zmieniając plik:

IP6TABLES_SAVE_ON_STOP="no"

Do:

IP6TABLES_SAVE_ON_STOP="yes"

I to:

IP6TABLES_SAVE_ON_RESTART="no"

Do:

IP6TABLES_SAVE_ON_RESTART="yes"

To wydawało się zapisywać zmiany, które zrobiłem za pomocą poleceń iptables poprzez restart.

 5
Author: Dug,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-07 22:53:46

Umieść konfigurację IPtables w tradycyjnym pliku i zostanie ona załadowana po uruchomieniu:

/etc / sysconfig / iptables

 1
Author: BVB Media,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-22 08:40:06

W zeszłym miesiącu próbowałem skonfigurować iptables na kontenerze VM LXC, ale za każdym razem po ponownym uruchomieniu konfiguracja iptables nie była ładowana automatycznie.

Jedynym sposobem, aby go uruchomić było uruchomienie następującego polecenia:

Yum-y install iptables-services; systemctl disable firewalld; systemctl mask firewalld; service iptables restart; service iptables save

 1
Author: BVB Media,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-05 06:53:45

I aby dodać, powinieneś być w stanie zrobić to samo dla ip6tables po uruchomieniu systemctl mask firewalld polecenia:

    systemctl start ip6tables.service
    systemctl enable ip6tables.service
 0
Author: jman594,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-06 04:33:34

Jeśli to zrobisz i używasz fail2ban, musisz włączyć odpowiednie filtry/akcje:

Umieść następujące wiersze w /etc/fail2ban/jail.d/sshd.local

[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
logpath  = /var/log/secure
maxretry = 5
bantime = 86400

Włącz i uruchom fail2ban:

systemctl enable fail2ban
systemctl start fail2ban

Odniesienie: http://blog.iopsl.com/fail2ban-on-centos-7-to-protect-ssh-part-ii/

 0
Author: Sebas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-13 16:54:03