- 浏览: 191470 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (124)
- java (25)
- 项目学习 (7)
- Web JSP (14)
- English study (1)
- windows (17)
- Thinking in Java (2)
- SSD4 VB (1)
- VB.NET (9)
- CSS (11)
- JQuery (4)
- Struts2 (0)
- spring (1)
- Hibernate (1)
- Dojo (0)
- Prototype (0)
- JSON (1)
- Ajax (1)
- my life my computer (1)
- html (1)
- JavaCC (0)
- c# (1)
- C/C++ (1)
- SQL (0)
- PS (1)
- Linux (21)
- Flex (1)
- mysql (1)
最新评论
-
wshy33:
按照这个“去掉/jre/lib/ext/目录下的jaxen.j ...
xpath的使用遇到的问题 -
白色蜻蜓:
什么是ssh
Linux ---SSH密钥问题解决 -
lucane:
今天请教R大一个问题,然后用他提到的hsdis跑代码看,但是我 ...
JVM 反汇编动态运行代码 -
igotti:
原来-XX:+PrintAssembly还需要安装插件
JVM 反汇编动态运行代码 -
RednaxelaFX:
嗯Good,继续有新的同好开始鼓捣这些东西真好 ^_^我在编译 ...
JVM 反汇编动态运行代码
了解服务器防火墙 应该是玩服务器必须上的一课 。
linux的防火墙安全 的好坏 主要是 iptables 配置得如何,我认为。
于是乎,进入主题iptables的配置。(环境是centos 5.5)
iptables 需了解的几个基本概念: TARGET , CHAINS(user-defined and built-in chains), TABLE
1. TABLE
描述如下:
Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each table contains a number of built-in chains and may also contain user-defined chains.
2. CHAINS
描述如下:
Each chain is a list of rules which can match a set of packets. Each rule specifies what to do with a packet that matches.
This is called a ‘target’, which may be a jump to a user-defined chain in the same table.
chain 中包含各种规则(rule), 规则用来匹配数据包(packet), 同时了规则指定了如果匹配成功则对数据包(packet)做什么处理, 这就是所谓的target 。 也就是如果匹配成功,就交给taget 处理。
3. TARGETS
描述如下 :
A firewall rule specifies criteria for a packet, and a target. (可以忽略)
If the packet does not match, the next rule in the chain is the examined;
if it does match, then the next rule is specified by the value of the target, which can be the name of a user-defined chain or one of the special values ACCEPT, DROP, QUEUE, or RETURN. (这句话得认真看)
如果匹配成功,则数据包交给 由Target所决定的 下一条rule处理。 而Target 指定了什么? Target 可以是 用户定义的链,也可以是 ACCEPT ,DROP ,QUEUE,RETURN 。
接下来看看 这个四个单词是神马?
ACCEPT means to let the packet through.
DROP means to drop the packet on the floor.
QUEUE means to pass the packet to userspace. (How the packet can be received by a userspace process differs by the particular queue handler. 2.4.x and 2.6.x kernels up to 2.6.13 include the ip_queue queue handler. Kernels 2.6.14 and later additionally include the nfnetlink_queue queue handler. Packets with a target of QUEUE will be sent to queue number ’0’ in this case. Please also see the NFQUEUE target as described later in this man page.) (这个在此忽略!!!)
RETURN means stop traversing this chain and resume at the next rule in the previous (calling) chain. If the end of a built-in chain is reached or a rule in a built-in chain with target RETURN is matched, the target specified by the chain policy determines the fate of the packet.
其他三个不用解释了。
基本概念清理完毕,开始写脚本
#!/bin/bash # # iptables example configuration script # # # If connecting remotely we must first temporarily set the default policy on the INPUT chain to ACCEPT # otherwise once we flush the current rules we will be locked out of our server. # iptables -P INPUT ACCEPT # # Flush all current rules from iptables # iptables -F # # Allow SSH connections on tcp port 22 # This is essential when working on remote servers via SSH to prevent locking yourself out of the system # iptables -A INPUT -p tcp --dport 22 -j ACCEPT # # Allow Httpd on tcp port 22 # iptables -A INPUT -p tcp --dport 80 -j ACCEPT # # Set default policies for INPUT, FORWARD and OUTPUT chains # iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # # Set access for localhost # iptables -A INPUT -i lo -j ACCEPT # # Accept packets belonging to established and related connections # iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # # Create a new CHAIN called LOGNDROP # iptables -N LOGNDROP # # the standard DROP at the bottom of the INPUT chain is replaceed with LOGNDROP # iptables -A INPUT -j LOGNDROP # # # add protocol descriptions so it makes sense looking at the log # iptables -A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-prefix "Denied TCP: " --log-level 4 iptables -A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-prefix "Denied UDP: " --log-level 4 iptables -A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-prefix "Denied ICMP: " --log-level 4 # # drop the traffic at the end of the LOGNDROP chain. # iptables -A LOGNDROP -j DROP # Save settings # /sbin/service iptables save # # List rules # iptables -L -v
注释应该很详细了,提醒一点,上面定义了一个LOGNDROP 链, 并为该链添加了3条rules 。
附加修改syslog.conf的配置文件
# #config syslog # iptableslog=`cat /etc/syslog.conf | awk '{print $2}' | grep iptables.log` if [ "$iptableslog"="/var/log/iptables.log" ]; then echo "setup for iptables log Have already exists" else echo "# Save Denied messages to iptalbes.log" > /etc/syslog.conf echo "kern.warning /var/log/iptables.log" > /etc/syslog.conf fi
然后tail -f /var/log/iptables.log 查看被Denied的Packet, 可以看到来源的IP 。
这些都是iptables鸡毛蒜皮的小事情, iptables还大有文章,继续学习。
参考:
http://wiki.ubuntu.org.cn/IptablesHowTo#More_detailed_Logging_.E5.85.B3.E4.BA.8E.E6.97.A5.E5.BF.97.E8.AE.B0.E5.BD.95.E7.9A.84.E6.9B.B4.E5.A4.9A.E7.BB.86.E8.8A.82
http://wiki.centos.org/HowTos/Network/IPTables
发表评论
-
虚拟机centos静态配置IP
2011-08-14 09:14 2164修改三个文件: /etc/sysconfig/network ... -
linux 下文件监控
2011-02-27 21:07 1403使用 inotify 监控文件系统的活动 参考 ... -
安装centos 问题集锦
2011-02-27 19:06 1226问题:centos 网络安装后,无法使用grub 今天一天 ... -
重启服务器后无法远程登陆到mysql上
2011-02-27 19:05 1695RT,aimicheng连不上mysql ,而我碰到的问题 ... -
Linux 常用命令
2011-02-27 18:22 1211系统# uname -a # 查看内核/操作系统/CPU信 ... -
Ubuntu 常用的工具
2011-02-25 17:07 1240以前都是下载virtualbox之后再 dpkg -i 安装, ... -
svn 和 apache和php 安装 遇到的问题集锦
2011-02-24 17:30 1550svn : Unrecognized URL scheme ... -
Standby Suspend Sleep and Hibernate
2010-12-27 00:38 2253在linux下工作,经常不想把已经工作的环境全部关闭,每次 ... -
Linux ---SSH密钥问题解决
2010-10-31 23:44 1327之前每次SSH连接的时候,需要输入密码,今天在google r ... -
LInux---更改/usr/bin/目录下执行文件的权限出现的问题
2010-10-13 10:45 2879chmod 755 /usr/bin/* 这段代码直接导致 ... -
linux---grub 启动系统,出现“unknow filesystem, grub rescue >”
2010-10-11 00:22 4344原因:今天中午把硬盘重新分区,弄出了3个逻辑分区,和3个主分区 ... -
Fedora使用问题八:songtaste.com播放问题解决
2010-09-12 11:07 1075选择fedora 12. 更改源 yum --nogpgc ... -
fedora使用问题七:安装virtualbox时需要重新编译内核
2010-09-12 11:03 2368期间遇到如下问题 M ... -
Fedora使用问题六:geditor中文乱码解决
2010-07-07 07:14 1844在打开windows分区下的文本文件,和下载下来的文本文件时会 ... -
Fedora使用问题五:各种开发工具
2010-06-11 13:33 837下载下来是绿色版的,直接双击运行。 根本不用去使用yu ... -
Fedora使用问题四:内核版本的管理
2010-06-10 23:09 1012问题 :fedora自动更新后,之前的版本并没有删除 ... -
Fedora使用问题三:[Adobe Flash player]乱码不显示中文 Google在线音乐
2010-06-09 14:38 2142问题 :RT 解决办法 :修改/etc/fonts/ ... -
Fedora使用问题二:用户管理
2010-06-07 14:54 819转载: http://fedora.linuxsir. ... -
Fedora使用问题一:用户不能使用sudo命令
2010-06-07 14:33 2028Fedora 中关于sudo机制的一些事: 为了 ... -
面试中Linux备忘
2010-05-23 23:29 886/////////////////////////////// ...
相关推荐
必备知识 本文约定 1. 序言 1.1. 为什么要写这个指南 1.2. 指南是如何写的 1.3. 文中出现的术语 2. 准备阶段 2.1. 哪里能取得iptables 2.2. 内核配置 2.3. 编译与安装 2.3.1. 编译 2.3.2. 在Red Hat 7.1上...
一份说明IPTABLES基础知识的文档,含有详细使用说明和示例,内容较全面丰富,是一个学习LINUX 防火墙应用知识的材料。
安全体系概览,预备知识:OSI七层模型,Firewalls: netfilter/iptables,数据包的流向图(iptables语法,标准流程)
Iptables详细介绍秒速了Iptables的基本概念知识,运行环境,运行原理等内容。对Iptables的结构构成和各部分协同工作做了介艄。并对常用Iptables的操作代码做了解释并举例。看了此文档后,读者即可以学会对iptables的...
【小知识】20分钟掌握iptables指令
在介绍iptables之前,我们先来了解一下防火墙的相关知识: 防火墙存在于网络边界,通过预设规则对进出口路由进行检查的处理组件;防火墙分为包过滤防火墙和procy防火墙,(第二种称谓可能不太合适,欢迎大家来指点哦...
iptables手册详解,静态网页版,对netfile网络基础知识做全面介绍,详细讲解iptables命令以及应用场景。
iptables 马哥ppt 关于防火墙安全的知识
本篇文章整理了 iptables 的基本概念及入门知识,旨在帮助大家快速了解和使用 iptables。 关于更多 iptables 的扩展和实践部分将在后续篇章推出,敬请期待。
Iptables Tutorial 1.2.2 PDF,英文原版带书签,详细的讲述了iptable的原理、使用技巧,还补充了必要的tip/ip协议知识以便于理解。
linux下防火墙iptables 一、基本知识 二、iptable的安装与配置 禁止端口的实例 强制访问指定的站点 发布内部网络服务器 通过NAT上网 iptables实例
在本篇文章里小编给大家整理的是关于Linux netfilter/iptables知识点详解,有兴趣的朋友们可以参考下。
ebtables/iptables interaction on a Linux−based bridge
iptables指南,iptables命令基础大全。是网络学习者必备知识。
iptables的一些配置实例,基础知识!!
iptables;iptables工具;iptables工具;iptables工具;iptables工具;FilterTable的操作;FilterTable的操作;FilterTable的操作;FilterTable的操作;FilterTable的操作;FilterTable的操作;FilterTable的操作;NATTable的...
在知识共享( )下发布。 旨在为从未接触过iptables的中高级用户(或更高级别的用户)提供iptables简介。 这是iptables的粗略概述,并提供了一些基本示例。 传奇: 常用或提及不常用或此处未记录 iptables (和ip6...
iptables是一个管理netfilter的工具。这篇文章主要介绍了Linux使用iptables限制多个IP访问你的服务器的相关知识,需要的朋友可以参考下
如果你的IPTABLES基础知识还不了解,建议先去看看. 开始配置 我们来配置一个filter表的防火墙. (1)查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Chain INPUT (policy ACCEPT) target ...