参考:http://blog.abv.cn/?p=50

阿里云CentOS6默认没有启动iptables

1、检查iptables状态

[root@iZ94jj63a3sZ ~]# service iptables status
iptables: Firewall is not running.
[root@iZ94jj63a3sZ ~]#

  说明iptables没有启动。

  如果没有安装,则使用如下命令安装

[root@iZ94jj63a3sZ ~]# yum install -y iptables

  启动iptables

[root@iZ94jj63a3sZ ~]# service iptables start

 查看当前iptables的配置情况

[root@iZ94jj63a3sZ ~]# 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

2、清楚默认的防火墙规则

#首先在清除前要将policy INPUT改成ACCEPT,表示接受一切请求。
#这个一定要先做,不然清空后可能会悲剧
[root@iZ94jj63a3sZ ~]# iptables -P INPUT ACCEPT #清空默认所有规则
[root@iZ94jj63a3sZ ~]# iptables -F #清空自定义的所有规则
[root@iZ94jj63a3sZ ~]# iptables -X #计数器置0
[root@iZ94jj63a3sZ ~]# iptables -Z

3、配置规则

#允许来自于lo接口的数据包
#如果没有此规则,你将不能通过127.0.0.1访问本地服务,例如ping 127.0.0.1
[root@iZ94jj63a3sZ ~]# iptables -A INPUT -i lo -j ACCEPT #ssh端口22
[root@iZ94jj63a3sZ ~]# iptables -A INPUT -p tcp --dport -j ACCEPT #web服务端口80
[root@iZ94jj63a3sZ ~]# iptables -A INPUT -p tcp --dport -j ACCEPT #允许icmp包通过,也就是允许ping
[root@iZ94jj63a3sZ ~]# iptables -A INPUT -p icmp -m icmp --icmp-type -j ACCEPT #允许所有对外请求的返回包
#本机对外请求相当于OUTPUT,对于返回数据包必须接收啊,这相当于INPUT了
[root@iZ94jj63a3sZ ~]# iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT #过滤所有非以上规则的请求
[root@iZ94jj63a3sZ ~]# iptables -P INPUT DROP

4、保存

  首先使用 iptables -L -n 检查一下配置是否正确

[root@iZ94jj63a3sZ ~]# iptables -L -n

  确认无误后保存

[root@iZ94jj63a3sZ ~]# service iptables save

  添加到开机自启动

[root@iZ94jj63a3sZ ~]# chkconfig iptables on

阿里云CentOS6上配置iptables的更多相关文章

  1. 在阿里云服务器上配置CentOS+Nginx+Python+Flask环境

    在阿里云服务器上配置CentOS+Nginx+Python+Flask环境 项目运行环境 阿里云(单核CPU, 1G内存, Ubuntu 14.04 x64 带宽1Mbps), 具体购买和ssh连接阿 ...

  2. 阿里云服务器上使用iptables设置安全策略

    转自:http://www.netingcn.com/aliyun-iptables.html 公司的产品一直运行在云服务器上,从而有幸接触过aws的ec2,盛大的云服务器,最近准备有使用阿里云的弹性 ...

  3. 阿里云服务器上配置并使用: PHP + Redis + Mysql 从配置到使用

    (原创出处为本博客,http://www.cnblogs.com/linguanh/) 目录: 一,下载 二,解压 三,配置与启动 四,测试 Redis 五,配置 phpRedis 扩展 六,综合测试 ...

  4. 阿里云centOS6 下python安装及配置、pip安装及配置、ipython安装及配置

    我是在阿里云服务器上进行的python环境搭建,阿里云服务器会自带python但是版本低,所以打算自己安装一个,期间遇到各种问题,而且百度根本不够用无奈上的外网很快解决了.在此分享一下. 一.pyth ...

  5. 阿里云服务器上安装mysql的心路历程(博友们进来看看哦)

    在阿里云花了100买了一台云服务器,配置如下: CPU: 1核 内存: 512MB 数据盘: 0G 带宽: 1Mbps 阿里云服务器安装mysql搞得我想吐血,搞了一个多星期,现在才搞好,而且,还有许 ...

  6. Linux学习2-在阿里云服务器上部署禅道环境

    前言 以前出去面试总会被问到:测试环境怎么搭建?刚工作1-2年不会搭建测试环境还可以原谅自己,工作3-5年后如果还是对测试环境搭建一无所知,面试官会一脸的鄙视. 本篇以最简单的禅道环境搭建为例,学习下 ...

  7. 阿里云主机上安装jdk

    今天继续安装jdk到阿里云服务上,大家要看一下阿里云是32位还是64位的,如果是32位下载32位的包,如果是64位的下载64位的包 我的就是64位的,开始我还不知道是怎么区分32/64位的,原来X64 ...

  8. 阿里云 centos 环境配置与 django 部署

    1. 免密码登陆 # 本机生成密钥, 并将 pub 复制到阿里云服务器上 $ ssh-keygen -t rsa -P '' # -P表示密码,-P '' 就表示空密码 $ scp ~/.ssh/FI ...

  9. 关于阿里云ESC上go语言项目编译6l: running gcc failed: Cannot allocate memory

    (1)前段时间将自己的阿里云服务器上的系统由centos 6.5换为了ubuntu 14,其他的硬件配置都没有发生改变,将服务器上的数据恢复并且重新安装了golang的编译环境后,发现使用go bui ...

随机推荐

  1. [转] Loren on the Art of MATLAB

    http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/ Loren ...

  2. 在Visual Lisp中处理自动化错误

    Handling Automation errors in Visual LISP 翻译自原文Kean's blog:http://through-the-interface.typepad.com/ ...

  3. sql 语句 事务

    begin transactionbegin    insert into BlogUsers(BlogName) values ('测试');        insert into Posts(Po ...

  4. js之路

    开始记录js学习: udacity,edx上不去: 搞了一个html+css+JavaScript后开始看es6; 犀牛书,js启示录,你不知道的js上中: 第一个库jQuery及源码分析: --

  5. IOS 二维码的实现

    1.首先导入Coreimage框架. //创建滤镜对象 CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator&quo ...

  6. Angularjs scope

    $scope: var myapp = angular.module('myapp', []); myapp .controller('parent', function ($scope,$timeo ...

  7. Github账户注册的过程

    首先我通过冯老师的博客园帖子中的链接进入了注册地址,填写了用户名,邮箱,和密码.然后我进入我的邮箱验证了Github网站给我发送的验证信息,至此,我的GITHUB账户便注册完成了.

  8. Django 创建APP简单步骤

    yum install epel-releaseyum install python34yum install python-pippip install django django-admin st ...

  9. SHOI 2009 会场预约 平衡树 STL练习

    题目描述 PP大厦有一间空的礼堂,可以为企业或者单位提供会议场地.这些会议中的大多数都需要连续几天的时间(个别的可能只需要一天),不过场地只有一个,所以不同的会议的时间申请不能够冲突.也就是说,前一个 ...

  10. Extnet Direct 提交后台事件文件下载设置

    App.direct.MasterData.Export(App.tfSearch.getValue(), {                    isUpload: true            ...