码迷,mamicode.com
首页 > 系统相关 > 详细

使用Linux的iptables限制网络访问

时间:2016-10-04 08:00:47      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:linux   网络   用户   

简介:

iptables是用户态模块,主要进行规则配置;

netfilter是内核模块,负责实现过滤动作。

实例:

    1. iptables –F
    2. iptables –A INPUT –i lo –j ACCEPT
    3. iptables –A INPUT –s 127.0.0.1 –d 127.0.0.1 –j ACCEPT
    4. iptables –A INPUT –p icmp --icmp-type any –j ACCEPT
    5. iptables –A INPUT –p tcp –-dport 80 –j ACCEPT
    6. iptables –A INPUT –p tcp –s 114.114.114.114 –-sport 53 –j ACCEPT
    7. iptables –A INPUT –p udp –s 114.114.114.114 –-sport 53 –j ACCEPT
    8. iptables –A INPUT –p tcp –s 8.8.8.8 –-sport 53 –j ACCEPT
    9. iptables –A INPUT –p udp –s 8.8.8.8 –-sport 53 –j ACCEPT
    10. iptables –A INPUT –p tcp –s X.X.X.X –-sport 22 –j ACCEPT
    11. iptables –A INPUT –j DROP
    12. iptables –A FORWORD –j DROP

注意:

在配置防火墙策略时防止自己被关在服务器外面无法登陆,需注意以下两点:

1、在机房有值守人员时进行操作;

2、在正式环境部署前先在测试环境中进行部署。

使用Linux的iptables限制网络访问

标签:linux   网络   用户   

原文地址:http://chinahao.blog.51cto.com/5507815/1858569

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!