Solaris7 交流 -- 重新配置系统核心
发布时间:2006-10-14 8:48:29   收集提供:gaoqian
Sun Microsystems公司于前不久发布了它的新一代的旗帜性软件产品线:适用于SPARC  

和Intel两种计算机的新的Solaris 7 软件环境。Solaris 7产品系列包括基本的  

Solaris 7操作环境和3个模块化软件扩展版本(Solaris Easy Access Server,Solaris   

Enterprise Server,Solaris ISP Server)--每个扩展版本都在基本的Solaris 7操作  

环境上运行。新的产品线主要具有以下特点:  

1.    处理数据的能力大为增加,不仅数据量没有什么限制,计算的复杂性也有突破,  

为新一级的应用软件敞开了大门。  

2.    大型机的能力,而价格只有大型机的几分之一。  

3.    具有对PC机的完全互操作性,可使客户连接和管理他们的Windows NT环境与  

Solaris环境一样。  

4.    具有PC机简易管理的新风格,大大简化了安装与管理。  

不仅如此,该版本的Solaris还具有强大的软件支持,其中包括了Sun Visual WorkShop   

C++ 5.0软件和Sun Performance WorkShop Fortran 5.0软件,并为C/C++和  

Fortran的开发商开发企业级应用软件提供了具有竞争性的优势。Solaris 7具有全新中  

文版本,中文版本不仅具有多种中文输入方式、灵活地支持中文的输出,同时方便地接  

收中文邮件和进行字体转换弥补了过去Solaris在这方面的不足。Solaris 7与 Windows   

无缝连接,从而使用户可以进行简单明了的操作和管理。在Solaris 7中,Sun公司着重考  

虑了健壮和安全的问题,提供了一系列的现代化的安全机制,同时修补了安全漏洞和系统  

BUG,使得Solaris 7具有相当可靠的安全性和健壮性,将用户的风险降到了最低的限度。   

综上所述,Solaris 7是适用于企业网的操作系统。  

一、相关站点   

1.Solaris软件免费下载站点:  

http://www.sunfreeware.com/  

2.solaris 咨询站  

http://www.ibiblio.org/pub/packages/solaris/sparc/  

3.solaris中文手册:  

http://docs.sun.com/ab2?Ab2Lang=zh&Ab2Enc=gb2312  

4.UNIX depot  

http://www.cise.ufl.edu/depot/  

5.solaris中心  

    http://www.solariscentral.org/  
   
二、重新配置系统核心   

举例: Oracle 8 for solaris 2.6 安装的安装需要增加Shared Memory Segments;  

修改/etc/system文件,在文件后加上  

set shmsys:shminfo_shmmax=4294967295  

set shmsys:shminfo_shmmin=1  

set shmsys:shminfo_shmmni=100  

set shmsys:shminfo_shmseg=15  

set semsys:seminfo_semmns=200  

set semsys:seminfo_semmni=70  

set ulimit=3000000  

比如innd用的文件数目比较多,需要设置:  

set rlim_fd_max=4096  

set rlim_fd_cur=1024  

如何看系统默认值;  

先看系统默认值,超级用户可以用-k参数来看核心的各个参数,如果指定-w参数,则可  

以  

adb - general-purpose debugger  

可以看现在的值是什么?  

/usr/bin/adb –kw   

physmem 1f8d9  

maxusers/D   

maxusers:  

maxusers: 504  

maxusers/W 200  

maxusers: 0x1f8 = 0x200  

   

(1)IO相关的设置   

最经常需要改变的是文件描述符数因为SOCKET API处理INTERNET连接使用文件描述符,  

set rlim_fd_max = 8192  

set rlim_fd_cur = 4096  

Please, before you start, make a backup copy of your initial /etc/system.   

The backup should be located on your root filesystem. Thus, if some   

parameters fail, you can always supply the alternative, original system   

file on the boot prompt. The following shows two typically entered   

parameters:  

* these are the defaults of Solaris < 8 

set rlim_fd_max=1024 

set rlim_fd_cur=64 

rlim_fd_cur 

这个参数定义了一个进程可以打开文件描述符的“软”限制,该数目由当前运行的SHELL 

决定;ulimit –Sn,还可以通过setrlimit()函数来修改这个参数;不需要超级用户权 

限; 

The predicate rlim_fd_cur <= rlim_fd_max must be fulfilled. 

rlim_fd_max 

default 1024, recommended >=4096  

这个参数决定了一个进程可以打开文件描述符的“硬”限制;如果想改变该限制,必须  

有超级用户的权限;  

对于大多数SERVER,不管使用TCP还是UDP进行通讯,最大描述符数是每个用户进程的最  

重要的参数;文件描述符决定了同时可以连接的数目;  

ulimit -Hn  

You should consider a value of at least 2 * tcp_conn_req_max and you   

should provide at least 2 * rlim_fd_cur. The predicate rlim_fd_cur <= 

rlim_fd_max must be fulfilled. 

(2)进程相关的设置 

maxusers 

default 249 ~= Megs RAM (Ultra-2/2 CPUs/256 MB), min 8, max 2048, no 

recommendations 

最大用户定义系统可以支持的最大用户数,当核心生成的过程中,有一些表的大小就是 

由这个参数决定的。这个值的大小在当前SOALRIS版本中决定于内存的兆数目;有一些参 

数是由MAXUSER来决定的, 

_ The maximum number of processes on the system 

_ The number of quota structures held in the system 

_ The size of the directory name lookup cache(DNLC) 

默认值是系统内存兆数,小于2048; 

如果大于1024,必须在/etc/system中指定,如果大于4096,它的值为4096; 

当系统出现用户进程生成(FORK)缓慢时,系统报信息; 

out of processes 

默认值比较大有以下情况: 

数据库系统使用较大内存,但相对少的进程,减少MAXUSERS的值,可以节省系统内存; 

PIDMAX 

这个参数指定系统最大可能进程ID; 默认值为30000,范围为266到999999;只在启动 

时候进行设置; 

max_nprocs 

系统最大进程数,包含系统进程和用户进程;默认值为为10+(16*MAXUSERS) 

该值范围为266到MAXPID; 

基于Intel i386体系结构的Linux操作系统中,已经提供了这样的多进程运行的支持。 

通过合理的选择进程调度算法,可以获得比较好的平均相应时间和较高的系统性能。但 

是,美中不足的是,在目前的2.2.x版本的Linux内核中,存在对最大进程数的限制。也 

就是说,在目前的Linux系统中,最多只能有4090个用户进程同时存在。对于一般的桌面 

应用,这个数目是绰绰有余。但是,对于企业级的服务器应用来说,则是不够的。 

设想一个典型的Web服务器软件,它们一般都采用多进程/线程的结构。每当接到一个连 

接请求,就产生一个子进程/线程来处理。显然,对于一个重负载的服务器来说,同时有 

成千上万个连接是很常见的。而这时,采用kernel 2.2.x的系统就不能胜任了。因此, 

可以说正是因为存在这个最大进程数的限制,使得Linux不能胜任企业级服务器操作系统 

的工作。事实上,目前这个级别的操作系统一般都是较为成熟,并且没有上述限制的 

Solaris、AIX、HP-UX等系统。 

maxuprc 

一个用户可以生成的最大用户进程数; 

默认值为MAX_NPROCS-RESERVED_PROCS 

STREAM 

nstrpush 

默认值为9,这个参数定义了允许有多少个STREAM 模块加载在系统核心中,我猜想这个 

参数是指相对于一个用户或一个进程,通常不用修改该参数; 

strmsgsz 

默认值为 65536, 单个系统调用可以传给一个STREAM设备信息的数据部分的最大字节数 

;任何write(2)超过这个大小限制会被分为多个信息; 

范围为:0到262144 bytes 

当出现putmsg(2)系统调用返回ERANGE时,需要修改该参数; 

strctlsz 

默认值为 65536, 单个系统调用可以传给一个STREAM设备信息的控制部分的最大字节数 

;范围:0-MAXINT BYTES; 

General Kernel Variables 

noexec_user_stack 

Warning: This option might crash some of your application software, and 

endanger your system's stability! 

By default, the Solaris 32 bit application stack memory areas are set 

with permissions to read, write and execute, as specified in the SPARC 

and Intel ABI. Though many hacks prefer to modify the program counter 

saved during a subroutine call, a program snippet in the stack area can 

be used to gain root access to a system. 

If the variable is set to a non-zero value, the stack defaults to read 

and write, but not executable permissions. Most programs, but not all, 

will function correctly, if the default stack permissions exclude 

executable rights. Attempts to execute code on the stack will kill the 

process with a SIGSEGV signal and log a message in kern:notice. Program 

which rely on an executable stack must use the mprotect(2) function to 

explicitly mark executable memory areas. 

Refer to the System Administration Guide for more information on this 

topic. Admins which don't want the report about executable stack can set 

the noexec_user_stack_log variable explicitly to 0. 

Also note that the 64 bit V9 ABI defaults to stacks without execute 

permissions. 

TCP/IP参数设置 

TCP/IP参数可以由ndd工具来设置, 

Ndd命令能容易的在不重新配置系统内核和重起系统的情况下,修改核心和TCP/IP的设备 

的一些参数。使用如下命令可看到相应的帮助。 

#ndd /dev/arp \? 

? (read only) 

arp_cache_report (read only) 

arp_debug (read and write) 

arp_cleanup_interval (read and write) 

# ndd /dev/icmp \? 

? (read only) 

icmp_wroff_extra (read and write) 

icmp_def_ttl (read and write) 

icmp_bsd_compat (read and write) 

icmp_xmit_hiwat (read and write) 

icmp_xmit_lowat (read and write) 

icmp_recv_hiwat (read and write) 

icmp_max_buf (read and write) 

icmp_status (read only) 

#ndd /dev/ip \? 

? (read only) 

ip_forwarding (read and write) 

ip_respond_to_address_mask_broadcast(read and write) 

ip_respond_to_echo_broadcast (read and write) 

ip_respond_to_timestamp (read and write) 

ip_respond_to_timestamp_broadcast(read and write) 

ip_send_redirects (read and write) 

ip_forward_directed_broadcasts(read and write) 

ip_debug (read and write) 

ip_mrtdebug (read and write) 

ip_ire_cleanup_interval (read and write) 

ip_ire_flush_interval (read and write) 

ip_ire_redirect_interval (read and write) 

ip_def_ttl (read and write) 

ip_forward_src_routed (read and write) 

ip_wroff_extra (read and write) 

ip_ire_pathmtu_interval (read and write) 

ip_icmp_return_data_bytes (read and write) 

ip_send_source_quench (read and write) 

ip_path_mtu_discovery (read and write) 

ip_ignore_delete_time (read and write) 

ip_ignore_redirect (read and write) 

ip_output_queue (read and write) 

ip_broadcast_ttl (read and write) 

ip_icmp_err_interval (read and write) 

ip_reass_queue_bytes (read and write) 

ip_strict_dst_multihoming (read and write) 

ip_addrs_per_if (read and write) 

ip_ill_status (read only) 

ip_ipif_status (read only) 

ip_ire_status (read only) 

ip_ipc_status (read only) 

ip_rput_pullups (read and write) 

ip_enable_group_ifs (read and write) 

# ndd /dev/tcp \? 

? (read only) 

tcp_time_wait_interval (read and write) 

tcp_conn_req_max_q (read and write) 

tcp_conn_req_max_q0 (read and write) 

tcp_conn_req_min (read and write) 

tcp_conn_grace_period (read and write) 

tcp_cwnd_max (read and write) 

tcp_debug (read and write) 

tcp_smallest_nonpriv_port (read and write) 

tcp_ip_abort_cinterval (read and write) 

tcp_ip_abort_linterval (read and write) 

tcp_ip_abort_interval (read and write) 

tcp_ip_notify_cinterval (read and write) 

tcp_ip_notify_interval (read and write) 

tcp_ip_ttl (read and write) 

tcp_keepalive_interval (read and write) 

tcp_maxpsz_multiplier (read and write) 

tcp_mss_def (read and write) 

tcp_mss_max (read and write) 

tcp_mss_min (read and write) 

tcp_naglim_def (read and write) 

tcp_rexmit_interval_initial (read and write) 

tcp_rexmit_interval_max (read and write) 

tcp_rexmit_interval_min (read and write) 

tcp_wroff_xtra (read and write) 

tcp_deferred_ack_interval (read and write) 

tcp_snd_lowat_fraction (read and write) 

tcp_sth_rcv_hiwat (read and write) 

tcp_sth_rcv_lowat (read and write) 

tcp_dupack_fast_retransmit (read and write) 

tcp_ignore_path_mtu (read and write) 

tcp_rcv_push_wait (read and write) 

tcp_smallest_anon_port (read and write) 

tcp_largest_anon_port (read and write) 

tcp_xmit_hiwat (read and write) 

tcp_xmit_lowat (read and write) 

tcp_recv_hiwat (read and write) 

tcp_recv_hiwat_minmss (read and write) 

tcp_fin_wait_2_flush_interval (read and write) 

tcp_co_min (read and write) 

tcp_max_buf (read and write) 

tcp_zero_win_probesize (read and write) 

tcp_strong_iss (read and write) 

tcp_rtt_updates (read and write) 

tcp_wscale_always (read and write) 

tcp_tstamp_always (read and write) 

tcp_tstamp_if_wscale (read and write) 

tcp_rexmit_interval_extra (read and write) 

tcp_deferred_acks_max (read and write) 

tcp_slow_start_after_idle (read and write) 

tcp_slow_start_initial (read and write) 

tcp_co_timer_interval (read and write) 

tcp_extra_priv_ports (read only) 

tcp_extra_priv_ports_add (write only) 

tcp_extra_priv_ports_del (write only) 

tcp_status (read only) 

tcp_bind_hash (read only) 

tcp_listen_hash (read only) 

tcp_conn_hash (read only) 

tcp_queue_hash (read only) 

tcp_host_param (read and write) 

tcp_1948_phrase (write only) 

ndd命令语法为 

#ndd –set driver parameter 

显示当前值 

#ndd /dev/arp arp_debug 



0:代表特性禁止 

ndd –set /dev/arp arp_debug 1 

1:允许 

由于这些参数一般是经过优化过的,而且一旦改变失误,可能导致系统的不正常工作。 

所以sun不提供文档供人随意调节。 

See ndd(1M) for more information; 

但是tcp_conn_hash_size和ipc_tcp_conn_hash_size这两个参数只能在/etc/system中 

设置; 

如果想在系统启动过程中修改TCP/IP参数,需要将NDD命令加入启动脚本中。使用下面的 

方法来创建一个包含NDD命令的启动脚本; 

· 在/etc/init.d路径下建立一个脚本,并在相应 

/etc/rc2.d,/etc/rc1.d,/etc/rcs.d建立相应的连接; 

· 这个脚本必须在S69inet和S72inetsvc脚本之间; 

· 该文件名的前缀为S70或S71。有同一前缀的脚本连续执行,不会有什么问 

题; 

· 参阅/etc/init.d目录下的README文件获取更多的信息; 

  

tcp:tcp_conn_hash_size 

默认值为 256,在忙的服务器建议增加; 

控制TCP模块哈希表的大小 

$ ndd /dev/tcp tcp_conn_hash 

tcp_conn_hash_size = 256 

TCP dest snxt suna swnd rnxt rack rwnd 

rto mss w sw rw t recent [lport,fport] state 

251 f5bcf2a8 130.075.003.xxx 204a5e77 204a5e77 0000032120 e6255721 

e6255721 0000034752 

02000 01448 1 00 00 1 002a16c0 [22, 1022] TCP_ESTABLISHED 

The default size is printed when investigating the table. If you have a 

busy server, you might want to consider increasing the table's size. Mr. 

Storm reports that SUN increases the hash size up to 262144 for web 

server benchmarks. 

有关ARP协议的细节,请自己参阅相关文档。对于sun的系统,核心默认的ARP表过期的时 

间是5分钟,并且可以调节.另外一张表是ip层的路由表,它和arp表配合记录动态路由信 

息,20分钟过期,最后一个特性是”无偿ARP” ,即系统广播自己的硬件地址。这个特性 

用来诊断是否存在相同的硬件地址,另外也用来生成硬件地址的变动通知。 

1、ARP攻击 

针对ARP的攻击主要有两种,一种是DOS,一种是Spoof。 

ARP欺骗往往应用于一个内部网络,我们可以用它来扩大一个已经存在的网络安全漏洞。 

如果你可以入侵一个子网内的机器,其它的机器安全也将受到ARP欺骗的威胁。同样,利 

用APR的DOS甚至能使整个子网瘫痪。 

2、对ARP攻击的防护 

防止ARP攻击是比较困难的,修改协议也是不大可能。但是有一些工作是可以提高本地网 

络的安全性。 

首先,你要知道,如果一个错误的记录被插入ARP或者IP route表,可以用两种方式来删 

除。 

a. 使用arp –d host_entry 

b. 自动过期,由系统删除 

这样,可以采用以下的一些方法: 

1). 减少过期时间 

#ndd –set /dev/arp arp_cleanup_interval 60000 

#ndd -set /dev/ip ip_ire_flush_interval 60000 

60000=60000毫秒 默认是300000 

加快过期时间,并不能避免攻击,但是使得攻击更加困难,带来的影响是在网络中会大 

量的出现ARP请求和回复,请不要在繁忙的网络上使用。 

2). 建立静态ARP表 

这是一种很有效的方法,而且对系统影响不大。缺点是破坏了动态ARP协议。可以建立如 

下的文件。 

test.nsfocus.com 08:00:20:ba:a1:f2 

user. nsfocus.com 08:00:20:ee:de:1f 

使用arp –f filename加载进去,这样的ARP映射将不会过期和被新的ARP数据刷新,除 

非使用arp –d才能删除。但是一旦合法主机的网卡硬件地址改变,就必须手工刷新这个 

arp文件。这个方法,不适合于经常变动的网络环境。 

3).禁止ARP 

可以通过ifconfig interface –arp 完全禁止ARP,这样,网卡不会发送ARP和接受ARP 

包。但是使用前提是使用静态的ARP表,如果不在apr表中的计算机 ,将不能通信。这个 

方法不适用与大多数网络环境,因为这增加了网络管理的成本。但是对小规模的安全网 

络来说,还是有效和可行的。 

3、IP 

IP是用来传输数据的底层协议。 

4、IP Forwarding (IP转发) : 

IP 转发是在不同网卡之间路由包数据的过程。一般是用路由器来实现,但是拥有多网络 

接口的主机也可以实现。当有两个网络接口的时候,Solairs系统默认打开ip转发。 

关闭IP转发 

对于多宿主主机,存在可能的安全问题是,攻击者可能通过ip转发的方式访问到私有网 

络。在solaisr系统中,包转发能很的容易关闭。简单的生成一个文件 /etc/notrouter 

,就能在下次启动的时候关闭ip转发。 

另外通过ndd命令也能在系统运行的时候关闭ip转发。 

#ndd –set /dev/ip ip_forwarding 0 

严格限定多主宿主机 

如果是多宿主机,还可以加上更严格的限定防止ip spoof的攻击 

#ndd –set /dev/ip ip_strict_dst_multihoning 1 

默认是关闭的(值为0) 

转发包广播 

由于在转发状态下默认是允许的,为了防止被用来实施smurf攻击,关闭这一特性。 (参 

见cert-98.01) 

#ndd –set /dev/ip ip-forward_directed_broadcasts 0 

5、路由 

路由的过程就是检查路由信息,从而决定如何从哪个接口传输数据包的过程。即使一个 

桌面系统,也要有路由设置。路由表需要实时的升级。现在有多种路由协议可以用来路 

由数据。Solaris系统使用in.routed守护程序支持RIP version 1,使用in.rdisc守护 

进程支持ICMP路由更新。当solairs系统配置成为一个路由设备来转发数据包的时候,它 

通过上面的两种方式动态更新路由信息。 

6、攻击 

有多种方法能威胁动态路由协议。攻击者能伪造虚假的路由更新信息发送过来,从而达 

到DOS的效果;同样的方法,还能使数据报文转发到其他的网络上,使攻击者能监听数据 

。 

默认的solairs系统使用系统守护程序动态管理路由信息。静态路由很好的防止路由信息 

被远程动态改变。使用/etc/defaultrouter来设置本地子网的路由。使用route命令来 

设置其他路由信息。 

但是对于一个简单网络来说,使用静态路由是合适的,一旦网络中有较多的路由设备, 

必须使用动态路由。Solairs系统将来也会继续支持动态路由协议。 

转发源路由包。 

源路由包中包含了了指定数据如何路由的信息。因此攻击者可能使用源路由包绕过某些 

特定的路由器和防火墙设备,也可能用来避开一个已知的IDS系统的监控范围。在大多数 

solairs的应用系统上,是不需要这个特性的。由于solairs在打开ip转发以后默认支持 

源路由转发,所以我们必须手动关闭它 

#ndd –set /dev/ip ip_forward_src_routed 0 

7、ICMP 

ICMP:网络控制信息协议。下面讨论在IP驱动上配置solaris的ICMP特性。 

8、广播: 

ICMP广播经常会带来麻烦,这里有一条原则来防止广播风暴-控制ICMP的错误信息不被 

生成。为来防止攻击者利用ICMP实施DOS攻击,最好禁止本地网络对ICMP广播的响应。 

Solairs系统能调节三种ICMP广播的参数。 

响应Echo广播: 

Echo广播通常用来诊断网络主机的存活情况,一旦主机收到一个对广播地址的echo请求 

,默认情况下所有系统会回复这个广播要求。当有人恶意定制过量的echo包,系统中的 

流量将大为增加。因此我们可以关闭对echo广播的响应 

#ndd –set /dev/ip ip_respond_to_echo_boadcast 0 

响应时间戳广播 

时间戳通常用来同步两个不同系统的时钟,但是系统没有必要回复对广播地址发送的时 

间戳请求,所以我们可以关闭这种回应。 

#ndd –set /dev/ip ip_respond_to_timestamp_broadcast 0 

地址掩码广播 

地址掩码请求被用来确定本地掩码,通常是网络中无盘工作站在启动的时候发送。用下 

面的命令能禁止对这样请求的应答 

#ndd –set /dev/ip ip_respond_to_address_mask_broadcast 0 

9、重定向错误 

重定向错误:通常是路由器用来通知主机使用另一个路由器来传输数据的指示报文。报 

文重指定的路由器必须和发送路由器一样连接同一个子网,而收到报文的主机必须在自 

己的路由表里新增一条到那个子网的路由。不像ARP的包,这个路由不会过期也不会自动 

删除。很多系统检测这样的报文用来发现错误和潜在的问题,从而优先更改自己的路由 

表。 

接受重定向错误 

一个攻击者能伪造重定向错误的报文从而给目标主机装载一个新的路由,而这个路由也 

许更本就是错误的,这样主机就不会和一些特定的主机或网络通信,这是一种DOS(deny 

of service)攻击。虽然重定向报文本身有一些校验规则,但是这些规则能很容易的被欺 

骗。而且目前存在大量的工具来达到这个目的。大多数只有一条默认路由主机系统是不 

需要理会这种报文的,因此我们可以使用ndd命令忽略ICMP重定向错误报文。(solairs 

默认是不忽略的) 

#ndd –set /dev/ip ip_ignore_redirect 1 

发送重定向错误报文 

只有路由器才需要重定向错误,任何主机即使是多宿主主机也不需要发送这种报文,因 

此我们可以使用ndd来禁止本机发送错误重定向报文。 

Ndd –set /dev/ip ip_send_redirects 0 

时间戳响应 

就像前面提到的,时间戳广播报文在大多数环境下是不需要的。而solaris系统还能够完 

全不接受这种报文。 

#ndd –set /dev/ip ip_respond_to_timestamp 0 

关闭这个特性以后,有些使用rdate系统命令的unix主机将不能再同步时钟。但是 

solaris 2.6和7使用更好的时钟同步方式-NTP(网络时间协议),请参见xntpd的帮助。 

10、TCP   

TCP:传输控制协议  

11、SYN_flood攻击   

TCP-SYN flood又称半开式连接攻击,每当我们进行一次标准的TCP连接(如WWW浏览,下  

载文件等)会有一个一个三次握手的过程,首先是请求方向服务方发送一个SYN消息,服  

务方收到SYN后,会向请求方回送一个SYN-ACK表示确认,当请求方收到SYN-ACK后则再  

次向服务方发送一个ACK消息,一次成功的TCP连接由此就建立,可以进行后续工作了,  

如图所示:  

请求方 服务方  

---------------------> SYN  

SYN-ACK <---------------- 

----------------------> ACK  

  而TCP-SYN flood在它的实现过程中只有前两个步骤,当服务方收到请求方的SYN并  

回送SYN-ACK确认消息后, 请求方由于采用源地址欺骗等手段,致使服务方得不到ACK回  

应,这样,服务方会在一定时间处于等待接收请求方ACK消息的状态,一台服务器可用的  

TCP连接是有限的,如果恶意攻击方快速连续的发送此类连接请求,则服务器可用TCP连  

接队列很快将会阻塞,系统可用资源,网络可用带宽急剧下降,无法向用户提供正常的  

网络服务。  

对于solaris 2.5.1,只有安装了patch 103582-1(或以上)才能防止syn_flood.在  

synflood没有流行以前,连接队列和backlog队列是相同的,solairs 2.6/7和安装了  

patch以后的2.5.1系统,现在存在两条队列,一个是已连接的队列,一条是未连接完成的  

队列。SYN攻击时只能填充后一条队列,而且,一旦队列满,将随机丢弃老的syn包。系  

统还会监控这个队列被短时间填充的情况,一旦怀疑是syn_flood,将在系统的messages  

中记录下来。  

Mar 8 19:24:01 example unix: WARNING: High TCP connect timeout rate!   

System (port 80) may be under a SYN flood attack!  

新队列的大小也是可以调节的,繁忙的web服务器需要提高未连接队列的大小。默认的大  

小是1024,我们可以提高到4096。  

ndd –set /dev/tcp tcp_conn_req_max_q0 4096   

当然,一般情况下,核心的队列增大,系统的内存最好也应有相应的增加。  

12、连接耗尽攻击   

和SYN flood攻击不同,连接耗尽攻击不太常见。因为这种攻击必须使用真实IP,攻击的  

目标是已连接队列。许多系统有一个同时连接的上限,取决于核心参数和系统内存情况  

。作为通常的web服务器,这个上限值很难达到,因为http的连接是典型的短时连接。但  

是一个攻击者可能快速发送大量的连接请求,同时保持连接,这样正常访问者的连接就  

可能被服务器拒绝。  

我们可以通过优化系统核心和增加内存来缓解,但不是根本的方法。因为攻击者可能同  

时调动多台机器同时攻击。当然,我们可以在发现攻击以后,在防火墙或路由器上拒绝  

这些IP来源的连接。  

如果不通过网络设备,仅仅通过调节系统参数来缓解攻击。一方面,可以调节web   

server,如apache的timeout参数,减短连接保持时间,另一方面,我们可以将核心以连  

接队列参数增大(默认是128)。  

#ndd –set /dev/tcp tcp_conn_req_max_q 1024  

以上的方法能阻止大多数连接耗尽的攻击企图,除非攻击者调动更多的资源,发动大规模  

的DDOS,但这样会使攻击者更容易暴露。  

13、IP 欺骗   

IP欺骗基本原理:  

TCP连接的建立 :为了利用TCP连接交换数据,主机间首先必须建立一个连接。TCP建立连  

接时可以分为3个 步骤,称为三步握手法。如果主机A运行rlogin客户程序,并且希望连  

接到主机B上的rlogin daemon 服务器程序上,连接过程如图二所示。  

1 A ---SYN---> B  

2 A <--SYN/ACK--- B 

3 A ---ACK---> B  

图二  

需要提醒读者的是,主机A和B的TCP模块分别使用自己的序列编号。在时刻1时,客户端   

通过设置标志位SYN=1告诉服务器它需要建立连接。同时,客户端在其TCP头中的序列号   

域SEQ放置了它的初始序列号(ISN),并且告诉服务器序列号标示域是有效的,应该 被  

检查。在时刻2时,服务器端在接收了上面的SYN后,作出的反应是将自己的ISN和对客   

户端的ACKA发向客户端并且千知下一个期待获得的数据序列号是(ISN+1)。客户端在第  

一流时刻,对服务器的ISN进行确认。这时,数据传输就可以进行了。ISN与序列号的递  

增 了解序数编号如何选择初始序列号和如何根据时间变化是很重要的。似乎应该有这种  

情 况,当主机启动后序列编号初始化为1,但实际上并非如此。初始序列号是由  

tcp_init函 数确定的。ISN每秒增加128000,如果有连接出现,每次连接将反计数器的  

数值增加 64000。很显然,这使得用于表示ISN的32位计数器在没有连接的情况下每  

9.32小时复位 一次。之所以这样,是因为这样有利于最大限度地减少旧有连接的信息干  

扰当前连接的 机会。这里运用了2MSL等待时间的概念(不在本文讨论的范围之内。)如  

果初始序列 号是随意选择的,那么不能保证现有序列号是不同于先前的。假设有这样一  

种情况,在 一个路由回路中的数据包最终跳出了循环,回到了“旧有”的连接(此时其  

实是不同于 前者的现有连接(,显然会发生对现有连接的干扰。 端口号 为了提供对  

TCP模块的并行访问,TCP提供了叫做端口的用户接口。端口被操作系统内核 利用来标示  

不同的网络进程,也就是严格区分传输层入口的标示(就是说,IP不关心他 们的存在)  

。TCP端口与IP地址一起提供网络端到端的通信。事实上,在任何时刻任何Internet连接  

都能由4个要素来措述:源IP地址、源地址端口号、目的IP地址和目的地址。采样目标主  

机发出的TCP序列号,猜测出它的数据序列号。然后,伪装成被信任的主机, 同时建立  

起与目标主机基于地址验证的应用连接。如果成功,黑客可以使用一种简单的命令放置  

一个系统后门,以进行非授权操作。  

目前,RFC 1498定义了更好的随机ISN生成方法,使得这种攻击很难成功。对于solaris  

系统ISN生成有三种方式。  

0: 可预测的ISN  

1: 增强的ISN 随机生成  

2: RFC 1948描述的ISN生成方式  

所有版本的solaris默认生成方式值是1。2.5.1只有 0,1两种方式,2.6/7拥有0,1,2三种  

ISN 生成方式。  

我们可以修改/etc/default/inetinit文件来提高ISN的生成强度。  

将 TCP_STRONG_ISS=1改为 TCP_STRONG_ISS=2  

重起系统使他生效。对于solair 2.5.1,此方法无效。  

14、增加私有端口   

一般的情况下,1-1024端口被称为私有端口,只允许具有根权限的进程连接。但是有些大  

于1024的端口,即使需要这样的限制,却无法定义,如NFS的服务器端口2049,当然还有  

一些其他定义的高于1024的私有端口。  

在solairs2.5.1/2.6/7下使用如下方式,可以自定义最小的非私有端口  

ndd –set /dev/tcp tcp_smallest_nonpriv_port 2050   

这样以来,0-2049都被定义为私有端口。  

在solaris 2.6/7下,还能使用另一个参数单独指定私有端口。  

#ndd /dev/tcp tcp_extra_priv_ports  

2049  

4045  

用来显示已经定义的扩展私有端口  

#ndd –set /dev/tcp tcp_extra_priv_ports_add 6112  

来增加新的私有端口定义。  

使用 ndd –set /dev/tcp tcp_extra_priv_ports_del 来删除定义。  

要注意的是,不要随便定义私有端口,因为有些非根权限的进程会使用这些端口。特别  

是改变最小非私有端口这个参数,经常会引起问题。应仔细分析你的需求再用扩展私有  

端口定义的方式单独增加。  

15.tcp_max_buf  

最大缓存字节数;这个参数控制了由setsockopt(3SOCKET)函数设置发送和接收BUFFER  

大小;  

默认值:1048576  

范围为8192到1073741824  

如果在一个高速的网络环境中创建TCP连接,增加该值来与网速相适应;  

等等;   

   

16、附件:设置脚本,来源于sun公司   

#!/sbin/sh  

#  

# Copyright (c) 1999 by Sun Microsystems, Inc.  

# All rights reserved.  

#  

# $Id: nddconfig,v 1.2 1999/09/29 22:25:04 kaw Exp $  

#  

# Copy this script to /etc/init.d and name it 'nddconfig'. Create a  

# hardlink to /etc/init.d/nddconfig in /etc/rc2.d named 'S70nddconfig'.  

#  

# Keith A. Watson   

#  

PATH=/usr/bin:/usr/sbin   

#  

# This file contain network related options settings. The settings  

# included here are considered safe in terms of security. Some settings  

# may not work in your environment. The comments provided for each  

# explain what effect the setting has.  

#  

# A '0' indicates false/off.  

# A '1' indicates true/on.  

#  

#  

# arp_cleanup_interval  

#  

# This option determines the period of time the Address Resolution  

# Protocol (ARP) cache maintains entries. ARP attacks may be effective  

# with the default interval. Shortening the timeout interval should  

# reduce the effectiveness of such an attack.  

# The default value is 300000 milliseconds (5 minutes).  

#  

ARP_CLEANUP_INTERVAL=60000   

#  

# ip_forward_directed_broadcasts  

#  

# This option determines whether to forward broadcast packets directed  

# to a specific net or subnet, if that net or subnet is directly  

# connected to the machine. If the system is acting as a router, this  

# option can be exploited to generate a great deal of broadcast network  

# traffic. Turning this option off will help prevent broadcast traffic  

# attacks.  

# The default value is 1 (True).  

#  

IP_FORWARD_DIRECTED_BROADCASTS=0   

#  

# ip_forward_src_routed  

#  

# This option determines whether to forward packets that are source  

# routed. These packets define the path the packet should take instead  

# of allowing network routers to define the path.  

# The default value is 1 (True).  

#  

IP_FORWARD_SRC_ROUTED=0   

#  

# ip_ignore_redirect  

#  

# This option determines whether to ignore Internet Control Message  

# Protocol (ICMP) packets that define new routes. If the system is  

# acting as a router, an attacker may send redirect messages to alter  

# routing tables as part of sophisticated attack (man in the middle  

# attack) or a simple denial of service.  

# The default value is 0 (False).  

#  

IP_IGNORE_REDIRECT=1   

#  

# ip_ire_flush_interval  

#  

# This option determines the period of time at which a specific route  

# will be kept, even if currently in use. ARP attacks may be effective  

# with the default interval. Shortening the time interval may reduce  

# the effectiveness of attacks.  

# The default interval is 1200000 milliseconds (20 minutes).  

#  

IP_IRE_FLUSH_INTERVAL=60000   

#  

# ip_respond_to_address_mask_broadcast  

#  

# This options determines whether to respond to ICMP netmask requests  

# which are typically sent by diskless clients when booting. An  

# attacker may use the netmask information for determining network  

# topology or the broadcast address for the subnet.  

# The default value is 0 (False).  

#  

IP_RESPOND_TO_ADDRESS_MASK_BROADCAST=0   

#  

# ip_respond_to_echo_broadcast  

#  

# This option determines whether to respond to ICMP broadcast echo  

# requests (ping). An attacker may try to create a denial of service  

# attack on subnets by sending many broadcast echo requests to which all  

# systems will respond. This also provides information on systems that  

# are available on the network.  

# The default value is 1 (True).  

#  

IP_RESPOND_TO_ECHO_BROADCAST=0   

#  

# ip_respond_to_timestamp  

#  

# This option determines whether to respond to ICMP timestamp requests  

# which some systems use to discover the time on a remote system. An  

# attacker may use the time information to schedule an attack at a  

# period of time when the system may run a cron job (or other time-  

# based event) or otherwise be busy. It may also be possible predict  

# ID or sequence numbers that are based on the time of day for spoofing  

# services.  

# The default value is 1 (True).  

#  

IP_RESPOND_TO_TIMESTAMP=0   

#  

# ip_respond_to_timestamp_broadcast  

#  

# This option determines whether to respond to ICMP broadcast timestamp  

# requests which are used to discover the time on all systems in the  

# broadcast range. This option is dangerous for the same reasons as  

# responding to a single timestamp request. Additionally, an attacker  

# may try to create a denial of service attack by generating many  

# broadcast timestamp requests.  

# The default value is 1 (True).  

#  

IP_RESPOND_TO_TIMESTAMP_BROADCAST=0   

#  

# ip_send_redirects  

#  

# This option determines whether to send ICMP redirect messages which  

# can introduce changes into remote system's routing table. It should  

# only be used on systems that act as routers.  

# The default value is 1 (True).  

#  

IP_SEND_REDIRECTS=0   

#  

# ip_strict_dst_multihoming  

#  

# This option determines whether to enable strict destination  

# multihoming. If this is set to 1 and ip_forwarding is set to 0, then  

# a packet sent to an interface from which it did not arrive will be  

# dropped. This setting prevents an attacker from passing packets across  

# a machine with multiple interfaces that is not acting a router.  

# The default value is 0 (False).  

#  

IP_STRICT_DST_MULTIHOMING=1   

#  

# tcp_conn_req_max_q0  

#  

# This option determines the size of the queue containing half-open  

# connections. This setting provides protection from SYN flood attacks.  

# Solaris 2.6 and 7 (and 2.5.1 with patch 103582-12 and higher) include  

# protection from these attacks. The queue size default is adequate for  

# most systems but should be increased for busy Web servers.  

# The default value is 1024.  

#  

TCP_CONN_REQ_MAX_Q0=4096   

# Process the argument. 'stop' ignored.  

case "$1" in  

'start')  

# set the appropriate network options  

ndd -set /dev/arp arp_cleanup_interval \  

$ARP_CLEANUP_INTERVAL  

ndd -set /dev/ip ip_forward_directed_broadcasts \  

$IP_FORWARD_DIRECTED_BROADCASTS  

ndd -set /dev/ip ip_forward_src_routed \  

$IP_FORWARD_SRC_ROUTED  

ndd -set /dev/ip ip_ignore_redirect \  

$IP_IGNORE_REDIRECT  

ndd -set /dev/ip ip_ire_flush_interval \  

$IP_IRE_FLUSH_INTERVAL  

ndd -set /dev/ip ip_respond_to_address_mask_broadcast \  

$IP_RESPOND_TO_ADDRESS_MASK_BROADCAST  

ndd -set /dev/ip ip_respond_to_echo_broadcast \  

$IP_RESPOND_TO_ECHO_BROADCAST  

ndd -set /dev/ip ip_respond_to_timestamp \  

$IP_RESPOND_TO_TIMESTAMP  

ndd -set /dev/ip ip_respond_to_timestamp_broadcast \  

$IP_RESPOND_TO_TIMESTAMP_BROADCAST  

ndd -set /dev/ip ip_send_redirects \  

$IP_SEND_REDIRECTS  

ndd -set /dev/ip ip_strict_dst_multihoming \  

$IP_STRICT_DST_MULTIHOMING  

ndd -set /dev/tcp tcp_conn_req_max_q0 \  

$TCP_CONN_REQ_MAX_Q0  

;;  

'stop')  

;;  

'show')  

echo "Currently unimplemented."  

;;  

*)  

echo "Usage: $0 { start | stop | show }"  

exit 1  

;;  

esac  

exit 0  

ndd - get and set driver configuration parameters  
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50