linuxË«Íø¿¨Íø¶ÎÍø¹ØÁ÷¿ØÅäÖÃ
Õâ¸öÎÊÌâÀ§ÈÅÎÒÖÁÉÙ2¸öÐÇÆÚÁË£¬·´·´¸´¸´²éÁ˺ܶà×ÊÁÏ£¬½ñÌìÖÕÓÚÄÜÅäÖÃÍê³É£¬ÏÖÔÚҪдÏÂÀ´¼¤¶¯°¡£¬²îµã¾ÍÆøÄÙÁË¡£
ÒªÇó£ºÎÒÏë×öipp2pµÄÁ÷Á¿¿ØÖƲâÊÔ£¬ËùÒÔÒªÔÚ¹«Ë¾ÄÚ²¿´î½¨Ò»¸ö²âÊÔ»·¾³¡£ÔÚÎÒͬ¹«Ë¾µÄÍøÖ®¼ä´î½¨Ò»Ì¨Ë«Íø¿¨µÄlinux»úÆ÷£¬¾ßÌåÓ²¼þ¼ÜÉèͼÊÇÕâÑùµÄ
»¥ÁªÍø
|
¹«Ë¾µÄÄÚ²¿Íø¶Î192.168.4.0(Íø¹ØÊÇ192.168.4.1)
|
eth1(IP 192.168.4.129)
linuxÖ÷»ú£¨Ë«Íø¿¨£©
eth2(IP 111.111.112.111)
|
ÎÒ×Ô¼ºµÄµçÄÔXPϵͳ(IP 111.111.112.112,Íø¹Ø 111.111.112.111)
Ç°ÆÚÅöµ½µÄÎÊÌâÊÇ,linuxÖ÷»úÄÜÉÏÍø,²¢ÇÒÄÜping¹«Ë¾µÄÄÚ²¿Íø¶Î192.168.4.0,µ«¾ÍÊÇping²»ÁËxpϵͳ»úÆ÷£¬Õâ¸öÎÊÌâÀ§ÈÅÁ˺ü¸Ì죬×îºó½â¾öµÄÊǹرÕÁËwindows·À»ðǽ,ÔÀ´ÊÇwindows·À»ðǽ·À»ðǽµ²×¡ÁËicmp°ü£¬Ê¹xpϵͳÄÜping linuxϵͳµÄË«Íø¿¨£¨²»ÄÜpingͨ¹«Ë¾Íø£©£¬µ«linux ping²»ÁËxpϵͳ»úÆ÷.
½â¾öÁËÕâ¸öÎÊÌ⣬ÏÖÔÚ¾ÍÊ£ÏÂÁËxpϵͳÄÜÉϹ«Ë¾ Íø¶Î192.168.4.0£¬»¹ÒªÄÜÉÏÍø
ÏÖÔÚÃþË÷³öÀ´µÄ½â¾ö·½°¸ÊÇ£¬¾²Ì¬Â·ÓÉÉèÖÃ+iptablesµÄnatת»»£¬Ê¹µÃXPϵͳ(IP 111.111.112.112)»úÆ÷ÄÜͨ¹ýeth1(IP 192.168.4.129)Õâ¸öipÉÏÍø£¬ÊµÏÖÁËnatµÄת»»
ÏÖÔÚÊǾ²Ì¬Â·ÓÉÅäÖÃÃüÁî
route add -net 111.111.112.0/24 gw 111.111.112.111 dev eth2
route add -net 192.168.4.0/24 gw 192.168.4.129 dev eth1
route add default gw 192.168.4.1
½ÓÏÂÀ´ÊÇiptablesµÄÅäÖÃ
iptables -t nat -F
iptables -t nat -A POSTROUTING -o eth1 -s 111.111.112.112 -j SNAT --to 192.168.4.129
iptables -t nat -A PREROUTING -i eth1 -d 192.168.4.129 -j DNAT --to 111.111.112.112
»¹Óиö¿ªÆôÄÚºËת·¢ echo 1 > /proc/sys/net/ipv4/ip_forward
ÎÒµÄÊÇred hat 2.6.18-8.el5 iptables v1.3.5
Íê³ÉÒԺ󣬷¢ÏÖXP»úÆ÷ÄÜping ¹«Ë¾192.168.4.0Íø¶Î£¬Ò²ÄÜÉÏÍøÁË¡£
Ïà¹ØÎĵµ£º
×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......
linuxϵĵ÷ÊÔ¹¤¾ß
Ëæ×ÅXPµÄÁ÷ÐУ¬ÈËÃÇÔ½À´Ô½×¢ÖØÈí¼þµÄÇ°ÆÚÉè¼Æ¡¢ºóÆÚµÄʵÏÖ£¬ÒÔ¼°¹á´©ÓÚÆäÖеIJâÊÔ¹¤×÷£¬¾¹ýÕâ¸ö¹ý³Ì³öÀ´µÄ×ÔÈ»ÊǸßÖÊÁ¿µÄÈí¼þ¡£ÉõÖÁÓÐÈËÉù³ÆXP »áÌÔ̵÷ÊÔÆ÷£¡Õ⵱ȻÊÇÓÐÒ»¶¨µÀÀíµÄ£¬È»¶ø¾ÍÄ¿Ç°µÄÏÖʵÀ´¿´£¬Õ⻹ÊÇÒ»ÖÖÀíÏë¡£ÔÚÈÕ³£¹¤×÷ÖУ¬µ÷ÊÔ¹¤¾ß»¹ÊDZز»¿ÉÉٵġ£ÔÚLinuxÏ£¬µ÷ÊÔ¹¤¾ ......
pid_t pid=fork()
it has 3 situation for the return result pid
0 child
>0 parent process
<0 fork fail
fork create a new process and it parent live alse when the child process had been created ......
Ò». ÖÕÖ¹½ø³ÌµÄ¹¤¾ß kill ¡¢killall¡¢pkill¡¢xkill
ÖÕÖ¹Ò»¸ö½ø³Ì»òÖÕÖ¹Ò»¸öÕýÔÚÔËÐеijÌÐò£¬Ò»°ãÊÇͨ¹ý kill ¡¢killall¡¢pkill¡¢xkill µÈ½øÐС£±ÈÈçÒ»¸ö³ÌÐòÒѾËÀµô£¬µ«ÓÖ²»ÄÜÍ˳ö£¬Õâʱ¾ÍÓ¦¸Ã¿¼ÂÇÓ¦ÓÃÕâЩ¹¤¾ß¡£
ÁíÍâÓ¦Óõij¡ºÏ¾ÍÊÇÔÚ·þÎñÆ÷¹ÜÀíÖУ¬ÔÚ²»Éæ¼°Êý¾Ý¿â·þÎñÆ÷³ÌÐòµÄ¸¸½ø³ÌµÄÍ£Ö¹ÔËÐУ¬Ò²¿ÉÒÔÓÃÕâЩ¹¤¾ßÀ´Ö ......