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. 准备开发一款开源NES模拟器

    前几天无意见看到一些NES的开发资料,勾起了小时候暑假的无数美好回忆,做为一名码农,萌发了自己写一款模拟器的想法.一来可以加深自己对整个系统/游戏的理解,一来可以实现小时候的梦想:),希望可以坚持下来 ...

  2. 类的static成员并用其实现一个单例模式

    对于特定类型的全体对象而言,有时候可能需要访问一个全局的变量.比如说统计某种类型对象已创建的数量.如果我们用全局变量会破坏数据的封装,一般的用户代码都可以修改这个全局变量,这时我们可以用类的静态成员来 ...

  3. 开启 mysql 远程访问

    如何开启MySQL的远程帐号-1)首先以 root 帐户登陆 MySQL 在 Windows 主机中点击开始菜单,运行,输入“cmd”,进入控制台,然后cd 进入MySQL 的 bin 目录下,然后输 ...

  4. iis 500.19错误解决过程记录

    前段时间一直在纠结C#中,dll的管理问题.最后选择使用nugetgallery进行公共库管理.项目地址:https://github.com/NuGet/NuGetGallery.这是一个nuget ...

  5. c# GridView有关RowClick事件,可单击显示选中的row

    //当前选定行 int i = this.gridView1.FocusedRowHandle; //选中行,列名为name的值 gridView1.GetRowCellDisplayText(i, ...

  6. JAVA获取服务器路径的方法

    1.在JSF环境中获取到ServletContext: 1 2 ServletContext sc = (ServletContext)FacesContext.         getCurrent ...

  7. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  8. AD6.8_mcu123 分享地址

    http://yunpan.cn/Qi3WrPPzEC2hI  访问密码 c07d

  9. 黑马程序员-NSDictionary和NSMutableDictionary

    NSDictionary和NSMutableDictionary:通过key和value进行对应,进行存储元素,能够方便提取所需的元素.key是不能够重复出现,但是value能够重复出现.NSDict ...

  10. 在wifi状态下没有数据线,链接手机调试

    因为不知道是手机的问题还是数据线的问题,经常链接不上adb 所以找了一下wifi情况下,无线跟eclipse链接调试 第一步,首先你需要在你的手机上安装一个终端模拟器工具 第二步,在终端里输入(需要r ...