vim /etc/iptables.rule

文件内容如下

*filter

# Allows all loopback (lo0) traffic and drop all traffic to / that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/ -j REJECT # Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allows all outbound traffic
# You could modify this to only allow certain traffic
-A OUTPUT -j ACCEPT # Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
-A INPUT -p tcp --dport -j ACCEPT
-A INPUT -p tcp --dport -j ACCEPT # Allows SSH connections for script kiddies
# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE
-A INPUT -p tcp -m state --state NEW --dport -j ACCEPT # Allow ping
-A INPUT -p icmp -m icmp --icmp-type -j ACCEPT # log iptables denied calls (access via 'dmesg' command)
-A INPUT -m limit --limit /min -j LOG --log-prefix "iptables denied: " --log-level # Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT COMMIT

测试这个脚本,iptables-restore < /etc/iptables.rule

如果发现iptables-restore v1.x.x: no command specified的错误,就把上面的脚本里面的空行全部删除,然后再重新回车添加

建立开机启动,vim /etc/init.d/start-iptables

#! /bin/sh
### BEGIN INIT INFO
# Provides: custom iptables
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
## Short-Description: custom iptables
### END INIT INFO /sbin/iptables-restore < /etc/iptables.rule

chmod +x /etc/init.d/start-iptables设置执行权限

rcconf添加这个脚本开机启动

debian7配置iptables的更多相关文章

  1. centos 7 配置iptables

    环境:阿里云ECS.centos 7 一.防火墙配置 不知道为什么,云主机没有开启firewall 或iptables,记录一下配置iptables防火墙的步骤 1.检测并关闭firewall sys ...

  2. 烂泥:KVM使用NAT联网并为VM配置iptables端口转发

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在前面的文章中,我们介绍KVM的虚拟机(以下简称VM)都是通过桥接方式进行联网的. 本篇文章我们来介绍KVM的VM通过NAT方式进行联网,并且通过配置I ...

  3. CentOS配置iptables规则并使其永久生效

    1. 目的 最近为了使用nginx,配置远程连接的使用需要使用iptable是设置允许外部访问80端口,但是设置完成后重启总是失效.因此百度了一下如何设置永久生效,并记录.  2. 设置 2.1 添加 ...

  4. 2-10~2-11 配置iptables防火墙增强服务 selinux简单讲解

    学习一个服务的过程: 1.此服务器的概述:名字,功能,特点,端口号 2.安装 3.配置文件的位置 4.服务启动关闭脚本,查看端口 5.此服务的使用方法 6.修改配置文件,实战举例 7.排错(从下到上, ...

  5. CentOS下配置iptables防火墙 linux NAT(iptables)配置

    CentOS下配置防火墙 配置nat转发服务CentOS下配置iptables防火墙 linux NAT(iptables)配置 CentOS下配置iptables 1,vim /etc/syscon ...

  6. Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站

    完整Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站 第一.安装和配置Apache Web服务器 运行升级命令来确保我们的系统组件各方面都是最新的. apt-get upd ...

  7. 使用Ansible安装部署nginx+php+mysql之配置iptables防火墙(0)

    前提: 1.已配置好hosts文件且免密码登录 2.需要的yaml文件已上传到主控端 一.使用Ansible配置iptables 1.iptables.yaml文件 --- - hosts: clon ...

  8. linux配置iptables

    iptables主要用来配置防火墙.其是一个需要特别谨慎设置的东西,服务器不在身边,不要贸然设置,有可能导致无法SSH,那就麻烦了. 1.首先介绍一下指令和相关配置文件 启动指令:service ip ...

  9. CentOS 6.x 配置iptables

    CentOS 6.x 配置iptables 来源 https://www.cnblogs.com/chillax1314/p/7976067.html iptables -P INPUT DROP-- ...

随机推荐

  1. 关于Conversion to Dalvik format failed with error 1错误

    在用Android导入一个新项目时,不知道为啥就碰上这个错误.在网上搜了半天,发现各种办法都有,但是最后居然是:将一个项目下的文件夹libs作为了source folder,而又在Proporties ...

  2. python应用-掷骰子模拟-pygal

    pygal安装: Linux下: pip install pygal Windows下: python -m pip install pygal 效果如图: # -*- coding: utf-8 - ...

  3. python判断key是否存在

    d = {: , : , : , : , : , : } def is_key_present(x): if x in d: print('Key is present in the dictiona ...

  4. vue 脚手架(二,项目依赖说明 package.json)

    本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 本文以转移至本人的个人博客,请多多关注! 继续上一篇, 上一篇讲了 vue ...

  5. 动态规划-Predict the Winner

    2018-04-22 19:19:47 问题描述: Given an array of scores that are non-negative integers. Player 1 picks on ...

  6. mysql中InnoDB存储引擎的行锁和表锁

    Mysql的InnoDB存储引擎支持事务,默认是行锁.因为这个特性,所以数据库支持高并发,但是如果InnoDB更新数据的时候不是行锁,而是表锁的话,那么其并发性会大打折扣,而且也可能导致你的程序出错. ...

  7. Leetcode 23.Merge Two Sorted Lists Merge K Sorted Lists

    Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list shoul ...

  8. Loops with PL/SQL

    1. Basic loop loop /* statements */ end loop; 2. While loop while a > b loop /* statements */ end ...

  9. 【MVC】ASP.NET MVC 4项目模板的结构简介

    引言     在VS2012新建一个窗体验证的MVC 4项目后,可以看到微软已经帮我们做了很多了,项目里面该有的都有了,完全可以看成一个简单网站.作为开发,能理解里面文件结构和作用,也算是半只脚踏进M ...

  10. 软件工程firstblood

    https://github.com/happyeven/WC 项目要求 wc.exe 是一个常见的工具,它能统计文本文件的字符数.单词数和行数.这个项目要求写一个命令行程序,模仿已有wc.exe 的 ...