ubuntu iptables设置【转】
root@qustdjx-K42JZ:/home/qustdjx# iptables -L -n
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
ubuntu中启动及关闭iptables
在ubuntu中由于不存在 /etc/init.d/iptales文件,所以无法使用service等命令来启动iptables,需要用modprobe命令。
启动iptables
modprobe ip_tables
关闭iptables(关闭命令要比启动复杂)
iptalbes -F
iptables -X
iptables -Z
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
modprobe -r ip_tables
依次执行以上命令即可关闭iptables,否则在执行modproble -r ip_tables时将会提示 FATAL: Module ip_tables is in use.
使用 ubuntu 已经有两个星期了, 才忽然发现原来一直都没有安装防火墙, 赶紧去找些资料看看, 下面给出我自己的 iptables设置,供和我一样新来的兄弟们参考,水平有限,多多指教。(对于防火墙的设置,有两种策略:一种是全部通讯口都允许使用,只是阻止一些我 们知道的不安全的或者容易被利用的口;另外一种,则是先屏蔽所有的通讯口,而只是允许我们需要使用的通讯端口。这里使用的是第二种原则,如果你需要开启其 他端口,请先参考计算机通讯口说明,然后自己添加。)
iptables -F
iptables -X
#抛弃所有不符合三种链规则的数据包
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
#设置:本地进程 lo 的 INPUT 和 OUTPUT 链接 ; eth1的INPUT链
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -m state --state ESTABLISHED,RELATED -jACCEPT
iptables -A INPUT -i eth1 -m state --state NEW,INVALID -j LOG
iptables -A OUTPUT -o lo -j ACCEPT
#对其他主要允许的端口的 OUTPUT设置:
# DNS
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 53 -jACCEPT
iptables -A OUTPUT -o eth1 -p UDP --sport 1024:65535 --dport 53 -jACCEPT
#HTTP
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 80 -jACCEPT
#HTTPS
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 443 -jACCEPT
#Email 接受 和发送
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 110 -jACCEPT
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 25 -jACCEPT
# FTP 数据和控制
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 20 -jACCEPT
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 21 -jACCEPT
#DHCP
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 68 -jACCEPT
iptables -A OUTPUT -o eth1 -p UDP --sport 1024:65535 --dport 68 -jACCEPT
#POP3S Email安全接收
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 995 -jACCEPT
#时间同步服务器 NTP
iptables -A OUTPUT -o eth1 -p TCP --sport 1024:65535 --dport 123 -jACCEPT
#拒绝 eth1 其他剩下的
iptables -A OUTPUT -o eth1 --match state --state NEW,INVALID -jLOG
最后是有关于iptables存储的命令:
因为iptables 在每次机器重新启动以后,需要再次输入或者调用,为了方便操作,使用
在
iface ath0 inet dhcp
后面加上
ubuntu iptables设置【转】的更多相关文章
- Ubuntu iptables 设置
在ubuntu中由于不存在 /etc/init.d/iptales文件,所以无法使用service等命令来启动iptables,需要用modprobe命令. 启动iptables modprobe i ...
- 阿里云服务器上使用iptables设置安全策略
转自:http://www.netingcn.com/aliyun-iptables.html 公司的产品一直运行在云服务器上,从而有幸接触过aws的ec2,盛大的云服务器,最近准备有使用阿里云的弹性 ...
- ubuntu下设置jupyter notebook 2017年07月29日 19:28:34 小旋锋 阅读数:8329 标签: ubuntu 更多 个人分类: python 二三事 来源:http://blog.csdn.net/suzyu12345/article/details/51037905 Ipython Notebook现在已经改名为Ipython jupyter,是最知名最好用的
ubuntu下设置jupyter notebook 来源:http://blog.csdn.net/suzyu12345/article/details/51037905 Ipython No ...
- [转载]ubuntu防火墙设置
原文地址:ubuntu防火墙设置作者:風飏 自打2.4版本以后的Linux内核中, 提供了一个非常优秀的防火墙工具.这个工具可以对出入服务的网络数据进行分割.过滤.转发等等细微的控制,进而实现诸 ...
- ubuntu下设置数据库字符集
就linux环境下出现的数据库乱码的问题,以ubuntu为例进行的总结 ubuntu环境设置的字符集utf8,windows默认字符集是GBK,Ubuntu的默认字符集为utf-8,这使 得在用tel ...
- Ubuntu iptables配置
sudo su sudo apt-get install iptables-persistent modprobe ip_tables #启动iptable #删除原有iptables规则 ipt ...
- ubuntu server设置时区和更新时间
ubuntu server设置时区和更新时间 今天测试时,发现时间不对,查了一下时区: data -R 结果时区是:+0000 我需要的是东八区,这儿显示不是,所以需要设置一个时区 一.运行 ...
- Ubuntu中设置静态IP和DNS
在Ubuntu中设置静态IP共两步:1>设置IP:2>设置DNS1>设置IP 编辑 /etc/network/interface文件: sudo vi /etc/n ...
- 在Ubuntu中设置中文输入法
在Ubuntu中设置中文输入法 */--> pre { background-color: #2f4f4f;line-height: 1.6; FONT: 10.5pt Consola,&quo ...
随机推荐
- ios之快速枚举
for(UIView * subView in self.view.subviews) { if([subView isKindOfClass:[XYZSeniorQueryView class]]) ...
- UITabBarController 详解之 hidesBottomBarWhenPushed的正确用法
今天说的是在TabBar嵌套Nav时,进行Push的时候隐藏TabBar的问题. 之前项目也需要这么做,那时候iOS7还没出,也是各种搜罗,后来的解决方法是当push操作的时候自己隐藏Tabbar,p ...
- 【linux】linux命令grep + awk 详解
linux命令grep + awk 详解 grep:https://www.cnblogs.com/flyor/p/6411140.html awk:https://www.cnblogs.com ...
- java容器的总结
1.什么是容器? 在程序中,容器是一种用来容纳对象的数据结构,比如说list.set .map.queue. 2.为什么需要容器? 我们为什么需要容器呢?因为在程序中,我们会在任意时刻和任意位置创建任 ...
- android之Android中的SQL查询语句LIKE绑定参数问题解决办法(sqlite数据库)
由于考虑到数据库的安全性,不被轻易SQL注入,执行查询语句时,一般不使用直接拼接的语句,而是使用参数传递的方法.然后在使用参数传递的方法中时,发现当使用like方式查询数据时,很容易出现一个问题. 错 ...
- 从阿里Java开发手册学习线程池的正确创建方法
前言 最近看阿里的 Java开发手册,上面有线程池的一个建议: [强制]线程池不允许使用 Executors 去创建,而是通过 ThreadPoolExecutor 的方式,这样的处理方式让写的同学更 ...
- jQuery中attr和prop方法的区别说明
jquery中attr和prop的基本区别可以理解为:如果是内置属性,建议用prop,如果是自定义的建议用attr. 例如 <input type=check node=123 id=ck & ...
- Chapter 4 -- Throwables
TODO: rewrite with more examples Guava's Throwables utility can frequently simplify dealing with exc ...
- 28个HTML5特征、窍门和技术
原文地址: http://www.zhangxinxu.com/wordpress/2010/08/%E7%BF%BB%E8%AF%91-%E4%BD%A0%E5%BF%85%E9%A1%BB%E7 ...
- 【google chrome 一键打开 谷歌跳转的页面+JS Replace】谷歌无法打开网页的时候,提取网页中url的部分
经常在谷歌搜索,遇到网页无法打开,然后就停留在比如:http://www.google.com.hk/search?newwindow=1&safe=strict&site=& ...