centos - 对 iptables 的更改没有效果。我的脚本有什么问题?

标签 centos iptables

这是我在 bash 中运行的 iptables 脚本。配置的保存是脚本的一部分。

#!/bin/bash
#
# iptables-konfigurasjon
#

# Set default rule to ACCEPT to avoid being locked out
iptables -P INPUT ACCEPT

# Flush all excisting rules
 iptables -F

# New default rules
 iptables -P INPUT DROP
 iptables -P FORWARD DROP
 iptables -P OUTPUT ACCEPT

# localhost:
 iptables -A INPUT -i lo -j ACCEPT

# Not entirely shure what this is about....:
 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow SSH.
 iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Allow http traffic for tomcat:
 iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

# Save rules:
 /sbin/service iptables save

但是,经过测试,这些规则似乎根本没有效果。
示例:如果我注释掉允许流量到我的 tomcat 服务器的行,我仍然可以从外部访问我的 tomcat 服务器......即使在重新启动后。

我的脚本有什么问题?

顺便说一句:我正在使用 CentOS 6。

最佳答案

将新添加的规则保存到您的iptables 后,您必须重新启动服务才能使更改生效。

/sbin/service iptables restart

或者
/etc/rc.d/init.d/iptables restart

关于centos - 对 iptables 的更改没有效果。我的脚本有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18047550/

相关文章:

centos - 获取cp : error while loading shared libraries: libc. so.6:无法打开共享对象文件:没有这样的文件或目录错误

bash - 通过 Cron 作业上传当天的备份而不是所有文件

imagemagick - CentOS 上的 Apple 的 SIPS 工具?

linux - 如何找出linux进程的打开文件描述?

c++ - 在 https 协议(protocol)的情况下,是否可以使用 libpcap 查看 header /数据包中的内容

mysql - 重启服务器后无法启动 MariaDB 10.3 数据库服务器

Linux iptables TRIGGER 目标描述

linux - libnetfilter_queue recv() 函数

bash - 读取文件的shell脚本

iptables - 最近使用 iptables 进行速率限制会出错