cod*_*gle 2 linux iptables centos5
我有一个带有运行 CentOS 的灯堆栈的开发服务器:
[Prompt]# cat /etc/redhat-release
CentOS release 5.8 (Final)
[Prompt]# cat /proc/version
Linux version 2.6.18-308.16.1.el5xen (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Tue Oct 2 22:50:05 EDT 2012
[Prompt]# yum info iptables
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.anl.gov
* extras: centos.mirrors.tds.net
* rpmfusion-free-updates: mirror.us.leaseweb.net
* rpmfusion-nonfree-updates: mirror.us.leaseweb.net
* updates: mirror.steadfast.net
Installed Packages
Name : iptables
Arch : x86_64
Version : 1.3.5
Release : 9.1.el5
Size : 661 k
Repo : installed
.... Snip....
Run Code Online (Sandbox Code Playgroud)
当我运行时:
service --status-all
Run Code Online (Sandbox Code Playgroud)
部分输出如下所示:
.... Snip....
httpd (pid xxxxx) is running...
Firewall is stopped.
Table: filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
....Snip....
Run Code Online (Sandbox Code Playgroud)
iptables 已加载到内核中,并且如显示的规则所示处于活动状态。
只检查 iptables 会返回规则,就像 status all 一样:
[Prompt]# service iptables status
Table: filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
.... Snip....
Run Code Online (Sandbox Code Playgroud)
启动或重启iptables表示iptables已经成功加载到内核:
[Prompt]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]
[Prompt]# service iptables start
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]
Run Code Online (Sandbox Code Playgroud)
我在谷歌上搜索过“防火墙已停止”。并阅读了许多 iptables 指南以及 RHEL 文档,但没有运气。
据我所知,没有“防火墙”服务,那么这条线"Firewall is stopped."指的是什么?
编辑- 这是一些额外的信息。
尽管“防火墙已停止”,iptables 仍在工作。服务状态的输出。
我在 iptables 中添加了一条规则,将 ssh 访问限制为仅一个 IP 地址(不是我的 IP 地址),并且在重新启动 iptables 后,我无法登录。
我有一个想法,这两个项目一个接一个地输出service --status-all是因为服务是按字母顺序输出的(只是一个猜测)。
那么,谁能解释为什么我看到“防火墙已停止”。即使 iptables 规则有效并且工作正常,我的服务状态是否输出?
解决方案
“防火墙已停止”。如果 iptables 或 ip6tables 关闭,则会出现消息。
如果两者都关闭,则(完全相同的)消息将出现两次(如果 ip6 的消息表明它指的是 ip6,那岂不是很好)。
如果服务开启,您也会看到错误消息,但您有一个空的规则表(就像我的 ip6 情况一样)。
信息由@Alexander Janssen 提供。有关 CentOS 5.8 默认 ip6 规则集的链接,请参阅答案。
| 归档时间: |
|
| 查看次数: |
76262 次 |
| 最近记录: |