首页 > 其他 > 详细

Centos防火墙添加IP白名单

时间:2018-09-25 18:18:05      阅读:198      评论:0      收藏:0      [点我收藏+]

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白名单

原文:https://www.cnblogs.com/erdi/p/9701049.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!