返回目录:设置问题
以oracle的1521端口为例
阻止所有zd服务器访问1521端口
iptables -I INPUT -p tcp --dport 1521 -j DROP
2
放行172.17.79.4
iptables -I INPUT -s 172.17.79.4 -p tcp --dport 1521 -j ACCEPT
3
保存配置
service iptables save
4
重启防火墙回
service iptables restart
5
后续如果想继续添加ip,执行2、答3、4步骤即可。
1、首先需要在Linux系统7a686964616fe58685e5aeb9337中查找并打开文件以编辑和配置防火墙,执行命令: vi /etc/sysconfig/iptables。
2、然后将以下语句添加到上面打开的文件中:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT(允许端口80通过防火墙,这里以端口80为例)。
请注意,上述语句不会加载文件的最后一面,这将导致防火墙无法启动。 应将正确的一个添加到默认的22端口规则中。
3、配置防火墙规则
# Manual customization of this file is not recommended.
4、重启防火墙,使配置生效。
/etc/init.d/iptables restart或者service iptables restart
重启如下:
扩展资料:
查看防火墙规则是否生效:
[root@localhost bin]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
root用户执行netstat -ntupl n表示不查询dns t表示tcp协议 u表示udp协议 p表示查询占用的程序 l表示查询正在监听的程序
打开配置文件
命令代码
[root@localhost ~7a64e58685e5aeb9366]# vi /etc/sysconfig/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 -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
-A INPUT -m state –state NEW -m tcp -p tcp –dport * -j ACCEPT
- 注意点:新开放的端口一定要在端口22后面
- 重启防火墙使配置生效
[root@localhost ~]# /etc/init.d/iptables restart
- 其它
- 查看开放端口
[root@localhost ~]# /etc/init.d/iptables status
- 关闭防火墙
[root@localhost ~]# /etc/init.d/iptables stop
配置代码
配置[*]通配代码
命令代码
命令代码
命令代码