原帖:http://www.cnscn.org/read.php?tid-44684.html
iptables有三种链
1:INPUT (进来的链)
2:OUTPUT(出去的链)
3:FORWARD(转发的链)
iptables -A INPUT -p icmp -j DROP
-A(添加一个链) -p 协议 -j(添加动作) 说明添加一个进来的链。协议是icmp动作拒绝。
iptables -L -n (用树形结构来看一下iptables的设置)
iptables -F (清空iptables的设置) 后面也可以加上INPUT 或者是OUTPUT
iptables --help | more (察看iptables的帮助)
iptables -L -n --line-numbres(察看iptables规则的编号)
iptables -A INPUT -p tcp -d 192.168.0.123 --dport 21 -j DROP
这句话是拒绝到本机的21端口。可以分析到目的地址是本机的192.168.0.123
目的端口是本机的21的端口 -d(目的地址) --dport(目的端口)。
下面我们来做一个实验来讲一下具体的配置。
例:假如我们服务器想配置一个WEB服务器。我们为了日后的维护。还要把SSHD打开
1:首先把所有规则DROP
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
P为大写
2 iptables -A INPUT -p tcp -d 192.168.0.123 --dport 22 -j ACCEPT
因为想要别人连我们的22 目的地址为本机的192.168.0.123 ......
http://hi.baidu.com/j_fo/blog/item/55f4014f1a226937aec3ab01.html
Linux Kernel Thread 的讨论
2007-05-14 11:45
kernel thread
Gearheads Written by Sreekrishnan Venkateswaran
Thursday, 15 September 2005
Threads are programming abstractions used in concurrent processing. A kernel thread is a way to implement background tasks
inside the kernel. A background task can be busy handling asynchronous
events or can be asleep, waiting for an event to occur. Kernel threads
are similar to user processes, except that they live in kernel space
and have access to kernel functions and data structures. Like user
processes, kernel threads appear to monopolize the processor because of
preemptive scheduling.
In
this month’s “Gearheads,” let’s discuss kernel threads and develop an
example that also demonstrates such as process states, wait queues, and
user-mode helpers.
Built-in Kernel Threads
To
see the kernel threads (also called kernel proce ......
http://www.cublog.cn/u/2108/showart_223258.html
Linux内核数据包处理流程-数据包接收
与其说这篇文章分析了网卡驱动中中数据包的接收,还不如说是以e100为例,对网卡驱动编写的一个说明。
当然,对数据包的接收说的很清楚。
转载
数据包的接收
作者:kendo
Kernel:2.6.12
一、从网卡说起
这并非是一个网卡驱动分析的专门文档,只是对网卡处理数据包的流程进行一个重点的分析。这里以Intel的e100驱动为例进行分析。
大多数网卡都是一个PCI设备,PCI设备都包含了一个标准的配置寄存器,寄存器中,包含了PCI设备的厂商ID、设备ID等等信息,驱动
程序使用来描述这些寄存器的标识符。如下:
CODE:
struct pci_device_id {
__u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
__u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
__u32 class, class_mask; /* (class,subclass,prog-if) triplet */
......
第一步,我们在Linux系统下,修改/etc/X11/xdm/Xaccess文件,找到下面的语句:
# * #any host can get a login window
去掉最前面的#号,成为
* #any host can get a login window
第二步,我们修改/etc/X11/gdm/gdm.conf文件,找到下面的语句:
[xdmcp]
Enable=false
将其中的Enable=false 改为Enable=true 或 Enable=1。
同时我们要确保存在下面的语句,因为177端口是我们要配置的xdmcp服务的监听端口,我们在后面配置xmanager将看。
Port=177
第三步,我们要修改/etc/inittab文件,将下面的语句
id:3:initdefault
改为如下,如果原来就是id:5:initdefault就不用更改。
同时,找到如下图文字所在的地方
x:5:respawn:/etc/X11/prefdm -nodaemon
将它修改为x:5:respawn:/usr/bin/gdm
第四步,我们修改/etc/X11/xdm/xdm-config的最后一行,在displayManager.requestPort:0前面加上一个!号,结果如下:
!DisplayManager.requestPort: 0
第五步,我们修改确保/etc/X11/xdm/Xservers的属性为444,/etc/X11/xdm/Xset ......
查看系统中开放的端口,关闭不需要的端口和程序,如下例中操作流程:
1. 查看对外开启的端口:
[root@mail ~]# nmap 127.0.0.1 #注:此处应该换作公网ip
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-04-20 11:06 CST
Interesting ports on 127.0.0.1
Not shown: 1668 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
1010/tcp open unknown
2. 对不明端口进行查访
[root@mail ~]# netstat -anlp | grep 1010
tcp 0 0 0.0.0.0:1010 0.0.0.0:* LISTEN 3796/rpc.statd
#
#[root@mail ~]# lsof -p 3796
#
#
[root@mail init.d]# which rpc.statd
/sbin/rpc.statd
[root@mail ~]# rpm -qf /sbin/rpc.statd
nfs-utils-1.0.9-40.el5
[root@mail init.d]# ll /etc/init.d/nfs*
-rwxr-xr-x 1 root root 4668 Jan 21 2009 /etc/in ......
http://hi.baidu.com/styl_007/blog/item/82b833f475036ce67609d7b6.html
中断处理的tasklet(小任务)机制-不过如此
2009-08-10 18:30
中断服务程序一般都是在中断请求关闭的条件下执行的
,
以避免嵌套而使中断控制复杂化。但是,中断是一个随机事件,它随时会到来,如果关中断的时间太长,
CPU
就不能及时响应其他的中断请求,从而造成中断的丢失。因此,Linux内核的目标就是尽可能快的处理完中断请求,尽其所能把更多的处理向后推迟。例如,假设一个数据块已经达到了网线,当中断控制器接受到这个中断请求信号时,
Linux
内核只是简单地标志数据到来了,然后让处理器恢复到它以前运行的状态,其余的处理稍后再进行(如把数据移入一个缓冲区,接受数据的进程就可以在缓冲区找到数据)。因此,内核把中断处理分为两部分:上半部(
tophalf
)和下半部(
bottomhalf
),上半部(就是中断服务程序)内核立即执行,而下半部(就是一些内核函数)留着稍后处理,
首先,一个快速的“上半部”来处理硬件发出的请求,它必须在一个新的中断产生之前终止。通常,除了在设备和一些内存缓冲区(如果你的设备用到了
DMA
,就不止这些)之间移动或传送数据, ......