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. How to build the Robotics Library from source code on Windows

    The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...

  2. 2-2. Initializing Objects with Initializer Lists

    Using Uniform Initialization to Construct a vector #include <iostream> #include <vector> ...

  3. TCP/IP协议工作原理简述

    TCP/IP协议工作原理简述 // */ // ]]>   TCP/IP协议工作原理简述 Table of Contents 1 概要 2 应用层 3 传输层 4 网络层 5 链路层 1 概要 ...

  4. POJ2632

    #include<stdio.h> #include<string.h> #include<algorithm> #include<cmath> usi ...

  5. PHP测试用例文档

    PHP接口测试用例和文档 PHP在过程中的测试 采用写一个简单html表单做一个简单的post测试 PHP接口测试文档 Alpha部分主要的接口文档可查看 接口文档 功能模块 接口 登录注册模块 验证 ...

  6. photoshopcc基础教程

    web项目中,除了最基础的用java存取数据外,还有重要的h5+css排版以及图片的ps,排版多多看网上人家的好看的界面设计,至于图片,只能自己上手了,设计最终的目的是好看,好看,好看. 接下来,做个 ...

  7. phpStudy 的Apache虚拟主机配置

    放弃了wamp,朋友介绍了phpstudy,不错的一款软件,关键是能自由切换php版本.相关的阿帕奇虚拟主机配置参考:http://www.th7.cn/system/win/201506/10846 ...

  8. VS与ultraedit 正则表达式替换

    ASP中把request("{param}")调用替换为requestX("{param}") VS 表达式替换(?<a>request\(&quo ...

  9. 如何彻底删除antlr-2.7.2.jar

    1 找到Local\MyEclipse\MyEclipse 10\configuration\org.eclipse.osgi\bundles\12\1\.cp\data\1.3\lib,将antlr ...

  10. myeclipse 10打开status.xml 卡死

    myeclipse里面的struts.xml的插件格式和要打开的文件格式不一样. 右键struts.xml   >    Open With  >  MyEclipse XML Edito ...