CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Centos防火墙添加IP白名单大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

Centos iptables防火墙添加IP白名单,指定IP可访问端口 vi /etc/sysconfig/iptables 以下为我虚拟机的防火墙为例(Centos 7) # sample configuration for iptables service # you can edit this manually or use system-config-firewall # please d

Centos iptables防火墙添加IP白名单,指定IP可访问端口

vi /etc/sysconfig/iptables

以下为我虚拟机的防火墙为例(Centos 7)

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

-N whitelist
-A whitelist -s xx.xx.xx.xx/32 -j ACCEPT    ##添加IP到白名单

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j whitelist    ##whitelist调用白名单IP列表,22端口只允许白名单IP使用
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT      ##无调用白名单,外网可访问
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -j REjeCT --reject-with icmp-host-prohibited -A FORWARD -j REjeCT --reject-with icmp-host-prohibited COMMIT ~

:wq   保存,重启防火墙生效

大佬总结

以上是大佬教程为你收集整理的Centos防火墙添加IP白名单全部内容,希望文章能够帮你解决Centos防火墙添加IP白名单所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。