TypechoJoeTheme

EYblog - Powered by Eyblog

统计
登录
用户名
密码

郑先森灬

世上没有偶然,有的只是必然,正面面对困难,才能迈向成功。
网站页面

【技术解读】iptables命令 关于Linux禁止IP大量请求命令

Linux服务器是如果存在恶意请求,可以使用Linux的防火墙机制去禁止这个IP

查看当前服务器IP请求量

netstat -tun|awk '{print $5}'|cut -d : -f1|sort|uniq -c|sort -n

语法
iptables(选项)(参数)

选项

-t<表>:指定要操纵的表;
-A:向规则链中添加条目;
-D:从规则链中删除条目;
-i:向规则链中插入条目;
-R:替换规则链中的条目;
-L:显示规则链中已有的条目;
-F:清楚规则链中已有的条目;
-Z:清空规则链中的数据包计算器和字节计数器;
-N:创建新的用户自定义规则链;
-P:定义规则链中的默认目标;
-h:显示帮助信息;
-p:指定要匹配的数据包协议类型;
-s:指定要匹配的数据包源ip地址;
-j<目标>:指定要跳转的目标;
-i<网络接口>:指定数据包进入本机的网络接口;
-o<网络接口>:指定数据包要离开本机所使用的网络接口。

iptables命令选项输入顺序:

iptables -t 表名 <-A/I/D/R> 规则链名 [规则号] <-i/o 网卡名> -p 协议名 <-s 源IP/源子网> –sport 源端口 <-d 目标IP/目标子网> –dport 目标端口 -j 动作

表名包括:

raw:高级功能,如:网址过滤。
mangle:数据包修改(QOS),用于实现服务质量。
net:地址转换,用于网关路由器。
filter:包过滤,用于防火墙规则。

规则链名包括:

INPUT链:处理输入数据包。
OUTPUT链:处理输出数据包。
PORWARD链:处理转发数据包。
PREROUTING链:用于目标地址转换(DNAT)。
POSTOUTING链:用于源地址转换(SNAT)。

动作包括:

accept:接收数据包。
DROP:丢弃数据包。
REDIRECT:重定向、映射、透明代理。
SNAT:源地址转换。
DNAT:目标地址转换。
MASQUERADE:IP伪装(NAT),用于ADSL。
LOG:日志记录。

实例
清除已有iptables规则

iptables -F
iptables -X
iptables -Z

开放指定的端口

iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT #允许本地回环接口(即运行本机访问本机)
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT #允许已建立的或相关连的通行
iptables -A OUTPUT -j ACCEPT #允许所有本机向外的访问
iptables -A INPUT -p tcp –dport 22 -j ACCEPT #允许访问22端口
iptables -A INPUT -p tcp –dport 80 -j ACCEPT #允许访问80端口
iptables -A INPUT -p tcp –dport 21 -j ACCEPT #允许ftp服务的21端口
iptables -A INPUT -p tcp –dport 20 -j ACCEPT #允许FTP服务的20端口
iptables -A INPUT -j reject #禁止其他未允许的规则访问
iptables -A FORWARD -j REJECT #禁止其他未允许的规则访问

屏蔽IP

iptables -I INPUT -s 123.45.6.7 -j DROP #屏蔽单个IP的命令
iptables -I INPUT -s 123.0.0.0/8 -j DROP #封整个段即从123.0.0.1到123.255.255.254的命令
iptables -I INPUT -s 124.45.0.0/16 -j DROP #封IP段即从123.45.0.1到123.45.255.254的命令
iptables -I INPUT -s 123.45.6.0/24 -j DROP #封IP段即从123.45.6.1到123.45.6.254的命令

查看已添加的iptables规则

iptables -L -n -v
Chain INPUT (policy DROP 48106 packets, 2690K bytes)
pkts bytes target prot opt in out source destination
5075 589K ACCEPT all – lo * 0.0.0.0/0 0.0.0.0/0
191K 90M ACCEPT tcp – * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
1499K 133M ACCEPT tcp – * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
4364K 6351M ACCEPT all – * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
6256 327K ACCEPT icmp – * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 3382K packets, 1819M bytes)
pkts bytes target prot opt in out source destination
5075 589K ACCEPT all – * lo 0.0.0.0/0 0.0.0.0/0

删除已添加的iptables规则

将所有iptables以序号标记显示,执行:

iptables -L -n –line-numbers

比如要删除INPUT里序号为8的规则,执行:

iptables -D INPUT 8
赞(0)
版权属于:

EYblog - Powered by Eyblog

本文链接:

https://akxdz.com/index.php/archives/72/(转载时请注明本文出处及文章链接)

评论 (71)
  1. Richardheest 作者
    Windows 10 · Google Chrome

    pain meds without written prescription best online canadian pharmacy buy prescription drugs from canada

    2022-05-15 回复
  2. Richardheest 作者
    Windows 8.1 · Google Chrome

    non prescription ed pills how to get prescription drugs without doctor prescription drugs online without doctor

    2022-05-14 回复
  3. Nathannus 作者
    Windows 10 · Google Chrome

    stromectol brand order stromectol over the counter stromectol 12mg online

    2022-05-11 回复
  4. Nathannus 作者
    Windows 7 · Google Chrome

    stromectol prices stromectol buy online stromectol pill price

    2022-05-09 回复
  5. Nathannus 作者
    Windows 8.1 · Google Chrome

    3000mg prednisone buy prednisone prednisone 10 mg

    2022-05-08 回复
  6. Nathannus 作者
    Windows 10 · Google Chrome

    Stromectol stromectol order stromectol gale

    2022-05-07 回复
  7. Nathannus 作者
    Windows 8.1 · Google Chrome

    treatment for erectile dysfunction ed clinic what type of medicine is prescribed for allergies

    2022-05-06 回复
  8. Jestine McCutcheon 作者
    MacOS · Google Chrome

    Hello, from CustomData.me we are a provider of unique databases that could help your business.

    Please visit us at CustomData.me to see if we can help you.

    Regards,
    Jestine

    2022-05-06 回复
  9. Joeann Challis 作者
    Ubuntu · FireFox

    Hello, from CustomData.click we are a provider of unique databases that could help your business.

    Please visit us at CustomData.click to see if we can help you.

    Regards,
    Joeann

    2022-05-05 回复
  10. RobertUSELS 作者
    Windows 10 · Google Chrome

    buy prednisone online from canada can i buy prednisone online in uk prednisone 10mg

    2022-05-02 回复
  11. RobertUSELS 作者
    Windows 10 · Google Chrome

    how to overcome ed naturally best way to treat ed pain meds online without doctor prescription

    2022-04-30 回复
  12. Victortoisa 作者
    Windows 10 · Google Chrome

    otc ed pills top erection pills mexican pharmacy without prescription

    2022-04-24 回复
  13. Victortoisa 作者
    Windows 10 · Google Chrome

    website ed dysfunction sildenafil without a doctor's prescription

    2022-04-22 回复
  14. Karla Dacey 作者
    Ubuntu · FireFox

    Hello.

    It is with sad regret to inform you TopDataList.com is shutting down.

    We have made all our databases available for you for a once off fee.

    Visit us on TopDataList.com

    2022-04-20 回复
  15. Simon Kelsall 作者
    Windows 10 · Google Chrome

    Hello.

    It is with sad regret to inform you TopDataList.com is shutting down.

    We have made all our databases available for you for a once off fee.

    Visit us on TopDataList.com

    2022-04-20 回复
  16. JasonDaync 作者
    Windows 8.1 · Google Chrome

    clomid for men buy clomid online cheap uk how can i get clomid in canada

    2022-04-20 回复
  17. Fay Ornelas 作者
    Ubuntu · FireFox

    ZippyLeads.org is running an easter special till the 18th of April.

    Get all the leads you need for your company with our easter special.

    2022-04-19 回复
  18. Jessika Collits 作者
    Windows 10 · Google Chrome

    ZippyLeads.org is running an easter special till the 18th of April.

    Get all the leads you need for your company with our easter special.

    2022-04-19 回复
  19. JasonDaync 作者
    Windows 10 · Google Chrome

    mens ed pills ed pills online best male enhancement pills

    2022-04-18 回复
  20. Josephboime 作者
    Windows 10 · Google Chrome

    where can i buy doxycycline doxycycline 100mg online doxycycline 100mg without a prescription

    2022-04-17 回复
  21. Josephboime 作者
    Windows 7 · Google Chrome

    clomid 150 mg buy online buy clomid for cheap buy clomid usa

    2022-04-15 回复
  22. Josephboime 作者
    Windows 7 · Google Chrome

    doxycycline 100mg price in south africa buy online doxycycline doxycycline 100g tablets

    2022-04-14 回复
  23. Aleida Gallegos 作者
    Ubuntu · FireFox

    Hello.

    We are offering Bullet Proof SMTP servers that never get suspended. Email as much as you want.

    DMCA ignored, bulletproof locations, 100% uptime guaranteed, unlimited data transfer, and 24/7/365 support.

    100 Spots available. BulletProofSMTP.org

    2022-04-13 回复
  24. Josephboime 作者
    Windows 8.1 · Google Chrome

    doxycycline over the counter nz doxycycline online usa doxycycline over the counter nz

    2022-04-13 回复
  25. RichardVen 作者
    Windows 8.1 · Google Chrome

    cialis generic shopping cialis 20 mg tadalafil buy cialis online cheap

    2022-04-09 回复
  26. Dadhar 作者
    Windows 7 · Google Chrome

    ivermectin bottle where to buy ivermectin for dogs stromectol 3 mg tablet

    2022-04-06 回复
  27. JaDiAl 作者
    Windows 10 · Google Chrome

    generic cialis online purchase kaboom cialis active ingredient in cialis

    2022-04-04 回复
  28. Breanna Leak 作者
    Ubuntu · FireFox

    It is with sad regret to inform you that LegitLeads.org is shutting down.

    We have made available over 300 million records for $149.

    Regards,
    LegitLeads.org

    2022-04-02 回复
  29. Malcolm Gerber 作者
    Windows 10 · Google Chrome

    It is with sad regret to inform you that TopDataList.com is shutting down.

    We have made available over 300 million records for $149.

    Regards,
    TopDataList.com

    2022-04-02 回复
  30. Jasonbof 作者
    Windows 7 · Google Chrome

    viagra cialis sample pack generic cialis online purchase rush delivery on cialis

    2022-03-29 回复
  31. Jasonbof 作者
    Windows 7 · Google Chrome

    what was viagra originally used for how much does viagra cost at walmart? free viagra samples by mail

    2022-03-27 回复
  32. Daviddum 作者
    Windows 10 · Google Chrome

    amoxicillin without a doctors prescription buy amoxicillin online mexico amoxicillin capsules 250mg

    2022-03-25 回复
  33. Daviddum 作者
    Windows 10 · Google Chrome

    doxycycline hyc doxycycline 100mg lowest price otc doxycycline no prescription

    2022-03-24 回复
  34. Daviddum 作者
    Windows 8.1 · Google Chrome

    chewable viagra viagra samples in canada maximum dose of viagra

    2022-03-23 回复
  35. Daviddum 作者
    Windows 10 · Google Chrome

    cost of doxycycline canada doxycycline 20 mg price doxycycline vibramycin

    2022-03-21 回复
  36. Marcusthake 作者
    Windows 7 · Google Chrome

    does ivermectin kill bacteria ivermectin scabies dose oral ivermectin for dogs

    2022-03-19 回复
  37. Marcusthake 作者
    Windows 10 · Google Chrome

    is ivermectin safe for pregnant goats ivermectin toxicity treatment why is stromectol prescribed

    2022-03-18 回复
  38. Marcusthake 作者
    Windows 10 · Google Chrome

    ivermectin to treat lyme gapeworm ivermectin ivermectin fleas

    2022-03-17 回复
  39. Columbus Nabors 作者
    Windows 10 · Google Chrome

    Hello,

    It is with sad regret to inform you that DataList.biz is shutting down. We have made all our databases available for you at a one-time fee.

    You can visit us on DataList.biz

    Regards.
    Columbus

    2022-03-17 回复
  40. Jameselirl 作者
    Windows 8.1 · Google Chrome

    best price on cialis cialis brand name without prescription cialis dosage 40 mg

    2022-03-14 回复
  41. Jameselirl 作者
    Windows 10 · Google Chrome

    walgreen cialis price cialis best price cheapest cialis tadalafil 20 mg

    2022-03-12 回复
  42. Russellepife 作者
    Windows 7 · Google Chrome

    paxlovid canada paxlovid components cigna envoy

    2022-03-11 回复
  43. Russellepife 作者
    Windows 7 · Google Chrome

    hydroxychloroquine price per pill what is plaquenil plaquenil and sun exposure

    2022-03-09 回复
  44. Russellepife 作者
    Windows 8.1 · Google Chrome

    molnupiravir cost molnupiravir cost per dose molnupiravir capsules 200 mg price in india

    2022-03-08 回复
  45. Melodee Redrick 作者
    Ubuntu · FireFox

    Hello,

    It is with sad regret to inform you that DataList.biz is shutting down. We have made all our databases available for you at a one-time fee.

    You can visit us on DataList.biz

    Regards.
    Melodee

    2022-03-08 回复
  46. Russellepife 作者
    Windows 8.1 · Google Chrome

    does hydroxychloroquine plaquenil and corona virus hcq 400 mg

    2022-03-07 回复
  47. Russellepife 作者
    Windows 10 · Google Chrome

    molnupiravir merck kaufen buy molnupiravir tablet how much does molnupiravir cost

    2022-03-06 回复
  48. Stevenprish 作者
    Windows 8.1 · Google Chrome

    buy generic viagra online usa viagra for men free samples is cialis better than viagra

    2022-03-03 回复
  49. Stevenprish 作者
    Windows 8 · Google Chrome

    viagra how to use the first time does viagra work for women how to tell if a man is taking viagra

    2022-03-02 回复
  50. MathewMiz 作者
    Windows 7 · Google Chrome

    buy cheap doxycycline online price of doxycycline - buy doxycycline monohydrate
    https://doxycyline1st.com/# generic doxycycline

    2022-02-27 回复
  51. Jamesdor 作者
    Windows 7 · Google Chrome

    clomid online clomid tablets - order clomid
    https://clomiphene1st.com/# clomid online

    2022-02-25 回复
  52. Stevenvap 作者
    Windows 10 · Google Chrome

    https://stromectolis.com/# stromectol oral

    2022-02-22 回复
  53. Stevenvap 作者
    Windows 7 · Google Chrome

    https://stromectolis.com/# stromectol tablet 3 mg

    2022-02-22 回复
  54. Stevenvap 作者
    Windows 10 · Google Chrome

    https://stromectolis.com/# buy liquid ivermectin

    2022-02-21 回复
  55. Stevenvap 作者
    Windows 8.1 · Google Chrome

    https://stromectolis.com/# purchase ivermectin

    2022-02-21 回复
  56. Stevenvap 作者
    Windows 7 · Google Chrome

    https://stromectolis.com/# ivermectin lice

    2022-02-21 回复
  57. Stevenvap 作者
    Windows 7 · Google Chrome

    https://stromectolis.com/# ivermectin cream

    2022-02-20 回复
  58. Stevenvap 作者
    Windows 7 · Google Chrome

    https://stromectolis.com/# ivermectin 80 mg

    2022-02-20 回复
  59. Chrisskelf 作者
    Windows 7 · Google Chrome

    ivermectin 400 mg brands: generic stromectol - ivermectin pills canada
    https://stromectolst.com/# ivermectin 50
    stromectol cvs ivermectin ivermectin 3 mg

    2022-02-18 回复
  60. Chrisskelf 作者
    Windows 10 · Google Chrome

    how much is ivermectin: ivermectin buy online - stromectol canada
    http://stromectolst.com/# ivermectin 1 topical cream
    stromectol oral generic stromectol ivermectin ebay

    2022-02-17 回复
  61. Georgelajow 作者
    Windows 8.1 · Google Chrome

    paxlovid price buy paxlovid cheap paxlovid
    https://apollobgshospitalsmysore.online/ paxlovid price
    paxlovid buy paxlovid online paxlovid for sale

    2022-02-17 回复
  62. Georgelajow 作者
    Windows 7 · Google Chrome

    paxlovid for sale paxlovid paxlovid cost
    https://myalliancehealthcare.online/ molnupiravir
    where to get molnupiravir molnupiravir for sale molnupiravir

    2022-02-15 回复
  63. JamesAmand 作者
    Windows 10 · Google Chrome

    mexican pharmacy without prescription canadian online drugstore canadian pharmacy online
    https://without-prescription-online.com/ comfortis for dogs without vet prescription
    canadian drugs best ed pills non prescription prescription drugs online without

    2022-02-12 回复
  64. JamesAmand 作者
    Windows 8 · Google Chrome

    online prescription for ed meds buy prescription drugs without doctor ed meds online without doctor prescription
    https://without-prescription-online.online/ ed meds online without prescription or membership
    online canadian drugstore best online canadian pharmacy buy prescription drugs

    2022-02-12 回复
  65. JamesAmand 作者
    Windows 10 · Google Chrome

    buy prescription drugs online legally amoxicillin without a doctor's prescription prescription drugs online without doctor
    https://without-prescription-online.online/ prescription drugs online without doctor
    buy canadian drugs buy prescription drugs from canada cheap canadian online drugs

    2022-02-12 回复
  66. GrantTOT 作者
    Windows 8 · Google Chrome

    zithromax coupon zithromax antibiotic without prescription zithromax over the counter
    https://azithromycin1st.com/ can you buy zithromax over the counter in canada
    zithromax order online uk zithromax 500 buy zithromax online fast shipping

    2022-02-10 回复
  67. GrantTOT 作者
    Windows 10 · Google Chrome

    zithromax price canada zithromax 500 without prescription how to get zithromax
    https://azithromycin1st.com/ zithromax for sale 500 mg
    where can i buy zithromax uk zithromax online paypal zithromax buy online

    2022-02-10 回复
  68. GrantTOT 作者
    Windows 8.1 · Google Chrome

    zithromax 500 mg lowest price drugstore online zithromax online no prescription buy zithromax online australia
    https://azithromycin1st.com/ buy azithromycin zithromax
    where can i buy zithromax capsules zithromax 500 mg zithromax prescription in canada

    2022-02-10 回复
  69. GrantTOT 作者
    Windows 7 · Google Chrome

    where can i get zithromax over the counter cheap zithromax pills zithromax 250 price
    https://azithromycin1st.com/ zithromax
    zithromax online usa no prescription zithromax 250 price zithromax order online uk

    2022-02-10 回复
  70. GrantTOT 作者
    Windows 10 · Google Chrome

    how to get zithromax online zithromax for sale usa zithromax for sale 500 mg
    https://azithromycin1st.com/ zithromax 500mg price in india
    buy cheap zithromax online zithromax 500 mg lowest price pharmacy online purchase zithromax z-pak

    2022-02-09 回复
  71. Timothypoism 作者
    Windows 7 · Google Chrome

    stromectol xr ivermectin for humans for sale - stromectol tablets buy online
    http://stromectolabc.online/ ivermectin purchase
    ivermectin buy online stromectol ivermectin 1 cream generic

    2022-02-04 回复
郑先森灬
世上没有偶然,有的只是必然,正面面对困难,才能迈向成功。
24 文章数
25,898 评论量

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月