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. 2018-2019-1 20189215 《Linux内核原理与分析》第六周作业

    <庖丁解牛>第五章书本知识总结 system_call并不是一个普通的函数,只是一段汇编代码的起点,且内部没有严格遵守函数调用堆栈机制. 通过set_system_trap_gate函数绑 ...

  2. 如何解决tensorflow报:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

    答:使能AVX,AVX2和FMA来进行源码编译,这样可以提速噢 具体编译方法,请参考windows10下如何进行源码编译安装tensorflow

  3. Codeforces Round #394 (Div. 2) B. Dasha and friends(暴力)

    http://codeforces.com/contest/761/problem/B 题意: 有一个长度为l的环形跑道,跑道上有n个障碍,现在有2个人,给出他们每过多少米碰到障碍,判断他们跑的是不是 ...

  4. 利用Html.css OPPO手机导航菜单的制作解析

    <body> <div id="top" class="auto"> <div class="nav"> ...

  5. HTML 入门1

    HTML   入门1  一,什么是HTML 超文本标记语言 二,如何写一个HTML文件? 1 通过sublime的文件->新建->保存 "文件名.html"格式 2,在 ...

  6. Mac系统下adb工具的配置

    sudo vim ~/.bash_profile 增加如下内容 ANDROID_HOME=/Users/apple/Library/Android/sdk export PATH=$PATH:$AND ...

  7. TensorFlow实现FM

    看了网上的一些用tf实现的FM,很多都没有考虑FM实际使用中数据样本稀疏的问题. 我在实现的时候使用 embedding_lookup_sparse来解决这个问题. 对于二阶部分,由于embeddin ...

  8. angular常用的服务

    在 AngularJS 中,服务是一个函数或对象,可在你的 AngularJS 应用中使用. AngularJS 内建了30 多个服务. $window$routeProvider 1. $http服 ...

  9. 第10章 Pry, 强大的pry-rails和相关的几个好用gem

    https://asciinema.org/a/0KtCL9HB1bP08wNHLfIeOMa8K 本章讲了如何定位❌,和排除bug. Pry  (5000

  10. Python的第一次作业

    题目1 : 描述:通过趣味的打怪来学习random随机函数. 代码: from random import * import types choc=0 hs=[100] numer=[randint( ...