centos上面防火墙配置例子

iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT #允许本地回环接口(即运行本机访问本机)
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT #允许已建立的或相关连的通行
iptables -A OUTPUT -j ACCEPT #允许所有本机向外的访问
iptables -A INPUT -p tcp –dport 22 -j ACCEPT #允许访问22端口
iptables -A FORWARD -j REJECT #禁止其他未允许的规则访问
iptables -I INPUT -s 123.45.6.7 -j DROP #屏蔽单个IP的命令
iptables -I INPUT -s 123.0.0.0/8 -j DROP #封整个段即从123.0.0.1到123.255.255.254的命令
iptables -nvL 查看已添加的iptables规则
iptables -nL –line-numbers 将所有iptables以序号标记显示
iptables -D INPUT 8 删除INPUT里序号为8的规则,
iptables -I INPUT -p icmp -j DROP 避免ping扫描
/etc/init.d/iptables save 保存iptable规则

-s 192.168.0.1 -d www.abc.com -p tcp –dport 80 匹配来自192.168.0.1,去往www.abc.com的80端口的TCP协议包
iptables -A INPUT -p tcp -m multiport –dports 22,21,25,80 -j ACCEPT 允许22,21,25,80端口通过

iptables -F 清除filter表中所有链上的规则,
iptables -F INPUT 清除INPUT链上的规则
service iptables save 保存防火墙命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值