linux 防火墙配置与REJECT导致没有生效问题
Posted djrLog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 防火墙配置与REJECT导致没有生效问题相关的知识,希望对你有一定的参考价值。
1.进入到/etc/sysconfig 如图
2.使用vi命令对iptables进行编辑."vi iptables",然后显示如图
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
3.新增mysql的端口3306,这里我们需要注意这行命令
-A INPUT -j REJECT --reject-with icmp-host-prohibited,这行已拒绝其他端口的命令,如果我们将新插入的
开放端口在放在这行命令之后的情况下,后面的配置开放的端口是不会被启用的。
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
4.然后调用service iptables resatar 命令
,显示如图代表成功。
[root@instance-9j07wgiz sysconfig]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
以上是关于linux 防火墙配置与REJECT导致没有生效问题的主要内容,如果未能解决你的问题,请参考以下文章
Linux ❀ 配置Linux操作系统不响应ICMP报文(防火墙放行/关闭情况下仍生效)