sudo su
sudo apt-get install iptables-persistent
modprobe ip_tables #启动iptable
 
#删除原有iptables规则
iptables -F
iptables -X
 
#抛弃所有不符合三种链规则的数据包
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
 
#设置:本地进程 lo  的 INPUT 和 OUTPUT 链接
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -jACCEPT
iptables -A INPUT -m state --state NEW,INVALID -j LOG
iptables -A OUTPUT -o lo -j ACCEPT
 
#打开 ssh 端口 控制 出和入
iptables -A INPUT  -p TCP  --dport 22 -j ACCEPT
iptables -A OUTPUT -p TCP --sport 22 --dport 1024:65535 -j ACCEPT
#打开 http端口 控制 出和入
iptables -A INPUT  -p TCP  --dport 80 -j ACCEPT
iptables -A OUTPUT -p TCP --sport 80 --dport 1024:65535 -j ACCEPT
#开出的端口,严格控制出入
#--------------------------------
 
#保存配置  存储位置/etc/iptables/iptables-persistent 会在开机启动时自动load之前的iptables设置
#iptables-persisten是bash脚本,位置在/etc/
service iptables-persistent save
 
--------------------------------------------------
2.关闭iptables
sudo su
iptables -F
iptables -X
iptables -Z
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
modprobe -r ip_tables

Ubuntu iptables配置的更多相关文章

  1. ubuntu开机自动加载iptables配置(转)

    原文:http://www.xuebuyuan.com/730127.html iptables的使用参见http://wiki.ubuntu.org.cn/IptablesHowTo iptable ...

  2. Ubuntu使用iptables配置防火墙提示:unrecognized service(Ubuntu配置iptables防火墙)

    Ubuntu默认安装是没有开启任何防火墙的. 当使用service iptables status时发现提示iptables:unrecoginzed service.意思是无法识别的服务. 以下方法 ...

  3. Ubuntu通过iptables配置 ip 代理转发

    开启 ip 代理转发 临时开启 ip 代理转发 # 执行该命令后立即生效,但是重启后会失效 echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward 永久开启 i ...

  4. SecureCRT连接虚拟机(ubuntu)配置

    使用SecureCRT连接虚拟机(ubuntu)配置记录   这种配置方法,可以非常方便的操作虚拟机里的Linux系统,且让VMware在后台运行,因为有时候我直接在虚拟机里操作会稍微卡顿,或者切换速 ...

  5. Linux操作系统下IPTables配置方法详解

    如果你的IPTABLES基础知识还不了解,建议先去看看. 们来配置一个filter表的防火墙 1.查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Cha ...

  6. ubuntu安装配置ssh-connect to host localhost port 22: Connection refused

    在安装ssh,经常出现 ssh: connect to host localhost port 22: Connection refused 从以下几点去检查: 1.是否安装ssh-server: 打 ...

  7. 《一个操作系统的实现》 ubuntu系统环境配置

    <一个操作系统的实现> ubuntu系统环境配置 电脑之前已经安装了gcc. 一.nasm安装:sudo apt-get install nasm或官网下载http://sourcefor ...

  8. Ubuntu中配置Java环境变量时,出现command not found问题解决记录

    百度出Ubuntu中配置Java环境变量时,在利用sudo gedit /etc/profile 对profile编辑后, 在terminal中输入 sudo source /etc/profile, ...

  9. Ubuntu下配置python完成爬虫任务(笔记一)

    Ubuntu下配置python完成爬虫任务(笔记一) 目标: 作为一个.NET汪,是时候去学习一下Linux下的操作了.为此选择了python来边学习Linux,边学python,熟能生巧嘛. 前期目 ...

随机推荐

  1. 用grunt进行前端工程化之路

    我们的项目wecash4.0的前端构建考虑过用fis和grunt. 目录: 前期调研:fis vs grunt vs gulp? 一.安装grunt和项目. fis是百度fex研发的构建工具,非常方便 ...

  2. Openfire 集群探究_压测情况

    一.(测试时间:20151220 - 下午14:00-17:00) windows环境 第一次测试,运行中发现在eclipse环境下.4w个连接耗尽了约1G的内存. 另外:服务本来可用的,压测客户端强 ...

  3. C#中指针的用法

    (*) unsafe 和 fixed unsafe { ]; ; i < array.Length; i++) { array[i] = i; } fixed (int* p = array) ...

  4. ocfs2: 搭建环境

    OCFS2是基于共享磁盘的集群文件系统,它在一块共享磁盘上创建OCFS2文件系统,让集群中的其它节点可以对磁盘进行读写操作.OCFS2由两部分内容构成,一部分实现文件系统功能,位于VFS之下和Ext4 ...

  5. linux下的redis安装以及php添加redis扩展

    一.redis的安装 win版本详见: 下面是linux版本的安装步骤: step1.下载 http://redis.io/download下载完后直接make然后make install,注意sud ...

  6. 未定义标识符string

    “未定义标识符string”  解决方法: 头文件加上 #include <iostream>using namespace std; string是标准库的,要加std::string, ...

  7. Android Fragment应用实战,使用碎片向ActivityGroup说再见

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/13171191 现在Fragment的应用真的是越来越广泛了,之前Android在3 ...

  8. MVC文件上传文件限制

    最近想实现MVC中文件上传限制,总觉得有便利的方法,找了半天就找到加属性accept <input type="file" id="file" name= ...

  9. gitlab安装过程总结

    gitlab总算搭建好了,今天下午完成了第一个工程的导入. 梳理下搭建的过程: 1.下载bitnami的一键安装包,并安装 注意设置权限为777,以免出现某文件写入错误的问题 2.配置邮件服务 分别修 ...

  10. easyUI的formatter使用

    <table class="easyui-datagrid" style="width:400px;height:250px" data-options= ...