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. 怎样获取本机的ip地址

    首先介绍一下用到的结构体 struct hostent { const char *h_name; // official name of host char **h_aliases; // alia ...

  2. Web工作原理

    第一步:寻找域名服务器,将域名(www.nice.com)的主机解析成服务器的ip的地址. 第二步:使用http协议连接Apache网页服务器,请求到服务器对应的目录下的文件,例如:index.php ...

  3. 优化openfire服务器,达到单机20万,集群50万

    openfire压测概述 个月左右的测试,总算得到预定目标(3台服务器,并发50w用户在线) 测试环境搭建 压测客户端无他-tsung,尝试了windows安装perl失败后,使用centOS6.5作 ...

  4. opencv 处女作

    显示一幅图:主要是运用功能:imread namedWindow imshowimread:从字面意思我们就可以看懂,用来读取图片的:namedWindow:显然,我们也可以看到这是用来命名窗口名称的 ...

  5. 使用AsyncTask实现文件下载并且在状态中显示下载进度

    2013年10月24日 上班的第二天 昨天我是用afinal完成的则个功能,但是公司里并不希望使用第三方的代码,所以要求我在不使用第三方开源项目的情况下实现. 最先我是使用Thread开启一个子线程, ...

  6. (转)linux下cp目录时排除一个或者多个目录的实现方法

    原文链接:http://www.jb51.net/LINUXjishu/88971.html 说明:/home目录里面有data目录,data目录里面有a.b.c.d.e五个目录,现在要把data目录 ...

  7. RHEL7学习之crontab无法执行ntpdate

    1,"/etc/crontab"文件 [root@localhost ~]# more /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/ ...

  8. [转]C#在创建完项目后如何重命名项目名称。

    今天写了个C#的小测试程序,一开始使用的默认命名WindowsFormsApplication2,写完后觉得名字不好看,于是想改个名字,但是试了一下,想完整的改名还挺复杂,不但要改解决方案名,项目名, ...

  9. asp.net C# cookies 的使用方法

    Response.Cookie("username").value="aa" 写入username=Request.Cookies("username ...

  10. apache和nginx开启https

    1.安装mod_ssl和openssl yum -y install mod_ssl openssl 2.建立服务器密钥 mkdir /etc/httpd/conf.d/ssl.key/ cd /et ...