debian7配置iptables
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的更多相关文章
- centos 7 配置iptables
环境:阿里云ECS.centos 7 一.防火墙配置 不知道为什么,云主机没有开启firewall 或iptables,记录一下配置iptables防火墙的步骤 1.检测并关闭firewall sys ...
- 烂泥:KVM使用NAT联网并为VM配置iptables端口转发
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在前面的文章中,我们介绍KVM的虚拟机(以下简称VM)都是通过桥接方式进行联网的. 本篇文章我们来介绍KVM的VM通过NAT方式进行联网,并且通过配置I ...
- CentOS配置iptables规则并使其永久生效
1. 目的 最近为了使用nginx,配置远程连接的使用需要使用iptable是设置允许外部访问80端口,但是设置完成后重启总是失效.因此百度了一下如何设置永久生效,并记录. 2. 设置 2.1 添加 ...
- 2-10~2-11 配置iptables防火墙增强服务 selinux简单讲解
学习一个服务的过程: 1.此服务器的概述:名字,功能,特点,端口号 2.安装 3.配置文件的位置 4.服务启动关闭脚本,查看端口 5.此服务的使用方法 6.修改配置文件,实战举例 7.排错(从下到上, ...
- CentOS下配置iptables防火墙 linux NAT(iptables)配置
CentOS下配置防火墙 配置nat转发服务CentOS下配置iptables防火墙 linux NAT(iptables)配置 CentOS下配置iptables 1,vim /etc/syscon ...
- Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站
完整Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站 第一.安装和配置Apache Web服务器 运行升级命令来确保我们的系统组件各方面都是最新的. apt-get upd ...
- 使用Ansible安装部署nginx+php+mysql之配置iptables防火墙(0)
前提: 1.已配置好hosts文件且免密码登录 2.需要的yaml文件已上传到主控端 一.使用Ansible配置iptables 1.iptables.yaml文件 --- - hosts: clon ...
- linux配置iptables
iptables主要用来配置防火墙.其是一个需要特别谨慎设置的东西,服务器不在身边,不要贸然设置,有可能导致无法SSH,那就麻烦了. 1.首先介绍一下指令和相关配置文件 启动指令:service ip ...
- CentOS 6.x 配置iptables
CentOS 6.x 配置iptables 来源 https://www.cnblogs.com/chillax1314/p/7976067.html iptables -P INPUT DROP-- ...
随机推荐
- InstallShieldpro2015 使用教程
1.下载地址:http://pan.baidu.com/s/1pLDCh3H ,如果网盘链接失效,请联系我. 2.解压后双击 3.安装完毕后,运行InstallShieldpro2015,会出现如下提 ...
- ssh-copy-id使用非默认22端口
ssh-copy-id使用及非默认22端口时报错 ssh-copy-id使用介绍 说明:ssh-copy-id命令可以把本地的ssh公钥文件安装到远程主机对应的账户下. 功能:ssh-copy-id ...
- [转]手机web HTML头信息解释和viewport meta标签解释
<meta charset="utf-8" /> <link rel="shortcut icon" href="favicon.i ...
- 2016湘潭邀请赛—Heartstone
http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1246 题意: 有n只怪,每只怪有指定的HP.现在1和2两种攻击方式,前者扣 ...
- Android 引用资源
比如在 strings.xml 中找到的 Hello world!字符串,我们有两种方式可以引用它: 1. 在代码中通过 R.string.hello_world 可以获得该字符串的引用: 2. 在 ...
- MOBA游戏学会这些知识,你才算真的入门了!
<英魂之刃口袋版>是一个标准的MOBA游戏,MOBA指的是多人在线战术竞技游戏,游戏模式始于1998年<星际争霸>中的一张自定义地图,经过近20年的优化和调整逐渐演变成了我们现 ...
- Leetcode 35
//在数组最后插入INT_MAX是个好方法class Solution { public: int searchInsert(vector<int>& nums, int targ ...
- jstack工具介绍
一.使用场景 当一个java应用CPU的使用比较高或者到达100%以上的时候,需要分析代码哪里有问题.这时候可以使用jstack命令 二.怎么使用 先使用命令ps –ef |grep keyword ...
- 003PHP文件处理——目录操作:rename scandir
<?php //目录操作:rename scandir /** * 修改目录名字: * rename('旧名字','新名字') 改变文件夹或者文件的名称 */ //var_dump(rename ...
- MissingNumber缺失的数字,FirstMissingPositive第一个缺失的正数
MissingNumber问题描述:给定一个数组,数组数字范围是0-n,找到缺失的数字.例如nums={0,1,3},return2. 算法分析:第一种方法,对数组进行排序,然后找到和下标不一致的数字 ...