centos 7에서 iptables를 어떻게 사용합니까? [닫은]
최소한의 구성 (os + dev 도구)으로 CentOS 7을 설치했습니다. httpd
서비스를 위해 80 포트를 열려고 하지만 iptables 서비스에 문제가 있습니다 ... 무엇이 잘못 되었습니까? 내가 무엇을 잘못하고 있지?
# 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.
RHEL 7 / CentOS 7에서는 iptables를 관리하기 위해 방화벽 이 도입되었습니다. IMHO, 방화벽은 서버 환경보다 워크 스테이션에 더 적합합니다.
보다 고전적인 iptables 설정으로 돌아갈 수 있습니다. 먼저 방화벽 서비스를 중지하고 마스킹하십시오.
systemctl stop firewalld
systemctl mask firewalld
그런 다음 iptables-services 패키지를 설치하십시오.
yum install iptables-services
부팅시 서비스를 활성화하십시오.
systemctl enable iptables
서비스 관리
systemctl [stop|start|restart] iptables
방화벽 규칙 저장은 다음과 같이 수행 할 수 있습니다.
service iptables save
또는
/usr/libexec/iptables/iptables.init save
RHEL 및 CentOS 7은 iptables 대신 firewall-cmd를 사용합니다 . 이런 종류의 명령을 사용해야합니다.
# add ssh port as permanent opened port
firewall-cmd --zone=public --add-port=22/tcp --permanent
그런 다음 규칙을 다시로드하여 모든 것이 정상인지 확인할 수 있습니다.
firewall-cmd --reload
lxc 또는 docker 컨테이너를 사용하려는 경우 iptable-save를 사용하는 것보다 espacially하는 것이 좋습니다. docker 서비스를 시작하면 iptable-save 명령이 프롬프트하는 몇 가지 규칙이 추가됩니다. 결과를 저장하면 저장하지 말아야 할 규칙이 많이 있습니다. 도커 컨테이너는 다음에 다시 부팅 할 때 IP 주소를 변경할 수 있기 때문입니다.
영구 옵션이있는 Firewall-cmd가 더 좋습니다.
"man firewall-cmd"를 확인하거나 공식 방화벽 문서 를 확인하여 옵션을 확인하십시오. 영역, 구성, 작동 방식 ...을 확인하는 많은 옵션이 있습니다. 맨 페이지가 실제로 완료되었습니다.
Centos 7부터 iptables-service를 사용하지 말 것을 강력히 권장합니다
재부팅하면 iptables가 시작되지 않는 문제가있었습니다.
이것은 그것을 고쳤다 :
yum install iptables-services
systemctl mask firewalld
systemctl enable iptables
systemctl enable ip6tables
systemctl stop firewalld
systemctl start iptables
systemctl start ip6tables
다음 명령을 시도하십시오 iptables-save
.
I modified the /etc/sysconfig/ip6tables-config
file changing:
IP6TABLES_SAVE_ON_STOP="no"
To:
IP6TABLES_SAVE_ON_STOP="yes"
And this:
IP6TABLES_SAVE_ON_RESTART="no"
To:
IP6TABLES_SAVE_ON_RESTART="yes"
This seemed to save the changes I made using the iptables commands through a reboot.
Put the IPtables configuration in the traditional file and it will be loaded after boot:
/etc/sysconfig/iptables
Last month I tried to configure iptables on a LXC VM container, but every time after reboot the iptables configuration was not automatically loaded.
The only way for me to get it working was by running the following command:
yum -y install iptables-services; systemctl disable firewalld; systemctl mask firewalld; service iptables restart; service iptables save
And to add, you should also be able to do the same for ip6tables after running the systemctl mask firewalld
command:
systemctl start ip6tables.service
systemctl enable ip6tables.service
If you do so, and you're using fail2ban, you will need to enable the proper filters/actions:
Put the following lines in /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
Enable and start fail2ban:
systemctl enable fail2ban
systemctl start fail2ban
Reference: http://blog.iopsl.com/fail2ban-on-centos-7-to-protect-ssh-part-ii/
참고URL : https://stackoverflow.com/questions/24756240/how-can-i-use-iptables-on-centos-7
'IT story' 카테고리의 다른 글
NSView의 배경색을 변경하는 가장 좋은 방법 (0) | 2020.06.18 |
---|---|
Android-startActivityForResult가 즉시 onActivityResult를 트리거 함 (0) | 2020.06.18 |
안드로이드의 EditText에 숫자 키보드를 어떻게 표시합니까? (0) | 2020.06.18 |
인증서가 만료되었거나 해지되었습니다 (0) | 2020.06.18 |
서비스 대리인 (SBMainWorkspace)이 xcode 8 오류를 거부했습니다. (0) | 2020.06.18 |