Flo*_*igl 3 iptables kickstart centos
作为系统强化的一部分,我尝试在 CentOS 6.6 kickstart 期间使用以下行配置我的防火墙。它确实在一种情况下起作用,否则就不起作用。
启动防火墙
firewall --enabled
--service=ssh --service=http --service=https
--port=53:udp,69:udp,25150:tcp,25151:tcp,3306:tcp
Run Code Online (Sandbox Code Playgroud)
这告诉它启用防火墙,并打开一组特定的服务。换行符是为了可读性,而不是配置的一部分。
我的包部分在下面,请注意:如果我添加 --nobase选项,iptables 处于直通模式,没有配置的痕迹。
一旦我删除 --nobase,iptables 就会正确设置,只有定义的一组开放端口。
启动包:
#%packages --nobase --excludedocs
%packages --excludedocs
@core
yum
wget
openssh-server
yum-downloadonly
screen
sysstat
lsscsi
ntpdate
rudder-agent
-nano
-selinux-policy
-selinux-policy-targeted
Run Code Online (Sandbox Code Playgroud)
我做了很多重新安装来追踪这个问题,并通过谷歌搜索发现有相当多的人结合了 --nobase 和 firewall --enabled --port设置。
另外,仅供参考:将 iptables 添加到包列表并没有什么不同。- 它是自动添加的。
如果您想知道,最终应用程序的软件供应商不允许启用 SELinux。
防火墙输出 1
这是添加 base 时的输出:
[host]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https
ACCEPT udp -- anywhere anywhere state NEW udp dpt:domain
ACCEPT udp -- anywhere anywhere state NEW udp dpt:tftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:25150
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:25151
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:mysql
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Run Code Online (Sandbox Code Playgroud)
防火墙输出 2
这是我使用 --nobase 的时候:
[host]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Run Code Online (Sandbox Code Playgroud)
问题:
是的,基本上,我只想填补那个缺失的依赖。如果无法找到它,我会将 iptables 配置置于操作系统安装之外的控制之下。我想避免这种情况,以便防火墙配置在第一次启动时就位并由默认机制生成,而不是一些插件。
您需要添加system-config-firewall-base包,该包提供lokkit用于在 kickstart 期间配置防火墙的命令。
RHEL的版本/ CentOS的之前6.6自动包括这个包,见https://bugs.centos.org/view.php?id=7956和https://bugzilla.redhat.com/show_bug.cgi?id=1161682为问题的讨论。