ÉèÖ÷À»ðǽ²ßÂÔʱ£¬¹ØÓÚSSH:22·ÃÎÊȨÏÞ£¬ÎÒÃdz£³£»áÉèÖ÷þÎñÆ÷Ö»½ÓÊÜij¸ö¹Ì¶¨IP(È繫˾IP)·ÃÎÊ£¬µ«Êǵ±ÎÒÃdzö²î»òÔÚ¼ÒÇé¿öÐèÒªµÇ¼·þÎñÆ÷Ôõô°ìÄØ£¿
³£ÓÃÁ½ÖÖ½â¾ö·½°¸£º1.ͨ¹ýVPN²Ù×÷µÇ¼Ö÷»ú£» 2.ʹÓÃpingÔ¿³×ÁÙʱ¿ªÆôÔ¶³ÌÖ÷»úSSH:22¶Ë¿Ú£»
ÎÒÃǽñÌì¾ÍÌÖÂÛµÚ2ÖÖ·½°¸£¬²ûÊöÈçºÎͨ¹ýpingÔ¿³×À´ÁÙʱ´ò¿ªSSH:22µÄ·ÃÎÊȨÏÞ
ÔÀí: recent Ä£¿é¿ÉÒԼǼ×î½ü·ÃÎÊÕßIP£¬³£ÀûÓô˹¦ÄÜ×öDROP²ßÂÔÓ¦¶Ôsyn-flood¼°ddos¹¥»÷¡£µ«ÔÚ±¾ÀýÖÐÎÒÃÇ·´ÆäµÀ£¬ÀûÓÃrecentÄ£¿é×öACCEPT²ßÂÔ£¬¾ÍÊÇ´´½¨Ò»¸össhKeyListÁÐ±í£¬µ±´ËÁбíÄÚµÄIPµØÖ·´ïµ½ÃüÖдÎÊýºó£¬È÷þÎñÆ÷·ÅÐдËIPµØÖ·¶ÔSSH:22¶Ë¿ÚµÄ·ÃÎÊ£¬ÎÒÃÇÒª×öµÄ¾ÍÊÇÏë°ì·¨½«ÎÒÃǵ±Ç°¿Í»§¶ËÕâ¸ö¶¯Ì¬IP¼Ç¼½øÈ¥£¬Ôõô¼Ç¼½øÈ¥ÄØ£¿ÀûÓÃpingÃüÁî¾Í¿ÉÒÔ£¬pingÃüÁî¿ÉÒÔ°ÑÔ´IP´ø¸øÔ¶³Ì·þÎñÆ÷°¡£¡pingÃüÁî¾ÍºÃ±ÈÒ»°ÑÁÙʱ´ò¿ªÔ¶³Ì·þÎñÆ÷SSH:22µÄÔ¿³×¡£
·½°¸: ÊÇÔ¿³×¾ÍµÃÓÐÔ¿³×³Ý£¬ÒªÓÐÒ»¶¨µÄ°²È«¼¶±ð£¬²»ÄÜÈÃÈËÄÇôÈÝÒײ³ö¹æÂÉ£¬ÔõôÔìÔ¿³×³ÝÄØ£¿lengthÄ£¿é¿ÉÒÔÆ¥Å䱨ÎÄ×ܳ¤¶È£¬ËùÒÔµÚ1¸öÔ¿³×³Ý¾ÍÊÇping°ü´óС±ØÐëÊÇÎÒÃÇ×Ô¶¨ÒåµÄ£¬µÚ2¸ö³Ý¾ÍÊÇpingµÄ´ÎÊýÒ²ÊÇÎÒÃÇ×Ô¶¨ÒåµÄ£¬µÚ3¸ö³Ý¾ÍÊÇÒªÔÚÖ¸¶¨µÄʱ¼äÄڵǼSSH:22¡£
С½áһϣ¬·þÎñÆ÷Ö»ÓÐÔÚ“Ö¸¶¨Ê±¼äÄÚÊÕµ½¹Ì¶¨´óСµÄping°ü+ping´ÎÊý”²ÅÁÙʱΪ´ËÔ´IP·ÅÐÐSSH:22¶Ë¿Ú·ÃÎÊȨ¡£
ʵʩ: ÈÎÒ»¿Í»§¶ËÏò·þÎñÆ÷·¢ËÍData´óСΪ1050×Ö½ÚµÄping°ü£¬·¢5´Î£¬·þÎñÆ÷¾Í×Ô¶¯Îª´Ë¿Í»§¶Ë¿ªÆôSSH:22¶Ë¿Ú·ÃÎÊȨÏÞ(30ÃëÄÚÓÐЧ)
×¢Ò⣺ICMP±¨ÎĽṹ: IPÍ·²¿(20Bytes) + ICMPÍ·²¿(8Bytes) + Êý¾Ý²¿·ÖData
¼ÆË㣺Èô°´´Ë·½°¸·þÎñÆ÷¶Ëʵ¼Ê½ÓÊÕµÄICMPÊý¾Ý°ü×Ü´óСΪ 20+8+1050=1078Bytes
¹æÔò: ¹²5Ìõ¹æÔò
# ¹æÔò1 Ö»½ÓÊÜDataΪ1078×Ö½ÚµÄping°ü£¬²¢½«Ô´IP¼Ç¼µ½×Ô¶¨ÒåÃûΪsshKeyListµÄÁбíÖÐ # iptables -A INPUT -p icmp -m icmp --icmp-type 8 -m length --length 1078 -m recent --name sshKeyList --set -j ACCEPT # ¹æÔò2 Èô30ÃëÄÚ·¢ËÍ´ÎÊý´ïµ½6´Î(¼°¸ü¸ß)£¬µ±·¢ÆðSSH:22ÐÂÁ¬½ÓÇëÇóʱ¾Ü¾ø # iptables -A INPUT -p tcp -m tcp --dport 22 --syn -m recent --name sshKeyList --rcheck --seconds 30 --hitcount 6 -j DROP # ¹æÔò3 Èô30ÃëÄÚ·¢ËÍ´ÎÊý´ïµ½5´Î£¬µ±·¢ÆðSSH:22ÐÂÁ¬½ÓÇëÇóʱ·ÅÐÐ # iptables -A INPUT -p tcp -m tcp --dport 22 --syn -m recent --name sshKeyList --rcheck --seconds 30 --hitcount 5 -j ACCEPT # ¹æÔò4 ¶ÔÓÚÒѽ¨Á¢µÄÁ¬½Ó·ÅÐÐ # iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT # ¹æÔò5 ÀϹæ¾Ø£º×îºóµÄ¾Ü¾ø # iptables -A INPUT -j DROP
²âÊÔЧ¹û
WindowsÏÂĬÈÏping´ÎÊýΪ4´Î£¬Ä¬ÈÏping°ü´óСΪ32×Ö½Ú
C:\Users\Administrator>ping 192.168.137.66 -l 1050 -n 5 ÕýÔÚ Ping 192.168.137.66 ¾ßÓÐ 1050 ×Ö½ÚµÄÊý¾Ý: À´×Ô 192.168.137.66 µÄ»Ø¸´: ×Ö½Ú=1050 ʱ¼ä<1ms TTL=64 À´×Ô 192.168.137.66 µÄ»Ø¸´: ×Ö½Ú=1050 ʱ¼ä<1ms TTL=64 À´×Ô 192.168.137.66 µÄ»Ø¸´: ×Ö½Ú=1050 ʱ¼ä<1ms TTL=64 À´×Ô 192.168.137.66 µÄ»Ø¸´: ×Ö½Ú=1050 ʱ¼ä<1ms TTL=64 À´×Ô 192.168.137.66 µÄ»Ø¸´: ×Ö½Ú=1050 ʱ¼ä<1ms TTL=64
LinuxÏÂĬÈÏping´ÎÊýΪÎÞÏ޴Σ¬Ä¬ÈÏping°ü´óСΪ56×Ö½Ú
[root@martin ~]# ping 192.168.137.66 -s 1050 -c 5 PING 192.168.137.66 (192.168.137.66) 1050(1078) bytes of data. 1058 bytes from 192.168.137.66: icmp_seq=1 ttl=64 time=0.711 ms 1058 bytes from 192.168.137.66: icmp_seq=2 ttl=64 time=1.00 ms 1058 bytes from 192.168.137.66: icmp_seq=3 ttl=64 time=0.629 ms 1058 bytes from 192.168.137.66: icmp_seq=4 ttl=64 time=1.32 ms 1058 bytes from 192.168.137.66: icmp_seq=5 ttl=64 time=1.02 ms
È»ºóÄØ£¬¾Í¿ÉÒԵǼSSHÁË(30ÃëÄÚÓÐЧ£¬¶¯×÷¿ìµã)£¬ÓÉÓÚÓÐ"--state ESTABLISHED -j
ACCEPT"»¤¼Ý£¬ËùÒÔÒ²²»Óõ£Ðı»Ìߣ¬OK£¬ÊµÏÖÔ¶³Ì°²È«SSHµÇ¼¹ÜÀí¾ÍÕâô¼òµ¥¡£
¡¡