-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare support #59
Comments
What connection range isn't getting blocked? maybe your ignore.ip.list is permitting the undesired connections. Also you should set the NO_OF_CONNECTIONS flag to the max desired amount of connections per ip. Also, how are you running ddos? in daemon/service mode or cron job? Just in case service mode is better. |
Hi, Im using centos 7, in daemon mode. I havent included anything in ignore.ip.list except my shared host ip for remote database: 192.3.x.x. Also, the ddos.conf is modified only for NO_OF_CONNECTIONS=100 and FIREWALL=iptables as i am using vestacp. My domain is under cloudflare-free, and my vps is using vestaCP. To clarify, when i simulate DOS on my ip/domain, the attacker IP (me) is only 1 hit, and excessive hits are delivered by cloudflare IPs (probably due to reverse proxy of nginx/cloudflare). I see in issue #27 that the author was able to modify for cloudflare/nginx use, but that was outdated and i am not confident with that fork. Please see the screenshot: http://prntscr.com/n3swe9 (the IP in red is my isp, which shows 1 hit. the IPs in orange are cloudflare servers with massive hits in just few seconds of running HULK dos) I cant set NO_OF_CONNECTIONS lower than 100, for possible web visitors who are using shared connections. |
Ok lets see if I understand correctly... You are using cloudflare to get some protection but instead cloudflare is distributing the dos attack on multiple servers and delivering it to your server? Isn't cloudflare supposed to prevent a dos attack since your server is behind their network? How do you know those orange connections are generated from your dos test? If that's the case then cloudflare is making matters worse (maybe on purpose)... Now I wonder if it's possible to monitor each connection cloud flare ip header (CF-Connecting-IP) using some tool since it is impossible to get that from ss or netstat alone (unless we scan a web server logs which seems unelegant)... that way we could know the real ip and add an iptable rule to drop those packets as I wrote on #27. Using a rule like Edit: Maybe using a tool like wireshark to sniff packets containing the CF ip header would be possible. |
Hi there,
My domain is behind cloudflare, and the vps is using VestaCP nginx+httpd. This is the out-of-box config section of nginx.conf http://prntscr.com/n4bjyh
Its range on https://www.cloudflare.com/ips , the vps/domain has few to no outside visit coz its still being tested. When i use HULK.py dos tool, my own ip is there, just marked as 1 hit, while the Cloudflare ips populated the ddos.sh logs with several hits and the vps became laggy. as soon as i close the hulk dos, that IPs vanish and vps resumes normal.
The prospect users of the developed site will be chatters.. in that case they could have same IPs.. dropping IPs could have a bad impact, or it could produce some internal errors due to blocking of proxy? I'm not really sure. I found this on stackoverflow, can a logic like this work on ddos.sh? https://stackoverflow.com/a/47127844 |
Could you try running this command on the vps:
to monitor the received packets which include the CF ip header and launch the hulk dos test tool again and report the output? Or much better run
launch the dos test with hulk and when finished kill tcpdump with CTRL-C and upload the output.pcap file so I can analyze it with tcpdump locally. Edit: The issue with these method of obtaining the real ip would be that on https connections I guess the CF-Connecting-IP header would be encrypted... so no way of reading it... making mandatory to read the server logs, but that is why I want you to test the method because I haven't used CF. |
Pre-dos https://budflick.com/output1.pcap |
Thanks! this worked beautifully:
With that we could maybe limit tcpdump for 1 second, grep the CF header and extract the ip's :) |
oh. so the logged CF-ips (in ddos -v) are false positive?
pardon me, i dont know :( ... the tcpdump only display my own ip, no cloudflare ip ranges. if in theory i have 100 users with the same IP accessing the site at the same moment, some of them would be dropped? (i set the connection limit to 100) update: the problem i see is that when i re-run the hulk.py dos, tcpdump shows the successive hits from my own ip. but in ddos -v my own ip shows 1-3 hits. effectively not hitting the connection limit as the hits are being distributed to that false-positive cf ips :( |
As it seems cloudflare is distributing each of your request to a different cloudflare server and sending it to your VPS as you wrote before with the orange square of ip's screenshot. So basically we need a new ddos.conf option named CF_MODE=true|false (accompanied with implementation for it) that when true would also use tcpdump to retrieve the list of ip addresses (by reading the CF-Connecting-IP) that are making multiple connections behind the CF servers and block them using iptables string matching module. I will try to implement it but I will need for you to test it to see if it is working. |
I will be on the look-out, if you need my vps i can lend you the login. I think its better that you can also see if i have misconfigs. edit i checked /var/log/ddos.log , and i saw that CF ips are being banned, and when i stop the hulkdos, my VPS ip is being banned/unbanned [2019-03-23 05:42:21] unbanned 162.158.111.242 that opened 19 connections i can still visit my site during and after hulkdos session. |
Ok, I added the experimental cloudflare support! You will need to update ddos,sh with the most recent one on this repo and add ENABLE_CLOUDFLARE=true on your ddos.conf file, then you can restart ddos service and retest with hulkdos. By the way the -v flag now also includes cloudflare ip addresses found on the tcpdump file when ENABLE_CLOUDFLARE=true so you can test that before running the hulkdos test. The tcpdump file is rotated every DAEMON_FREQ*2 seconds, not sure how well that will work so test and let me know. About these check #17 to see if that is your case
|
It worked! 👍 but with a note (merely cosmetic) the "normal" and "cloudflare" ip listing is displayed incorrectly. ddos -v https://prnt.sc/n4kxzz Could a logic be developed to exclude the cloudflare ips from the ddos -v display list?
Taken from: https://unix.stackexchange.com/questions/274330/check-ip-is-in-range-of-whitelist-array
/var/log/ddos.log now shows the correct info, and my server ip was not included on the ban (the fix was from the updated ddos.sh) I confirm sir that this work regardless of what is displayed on ddos -v and ddos -b now. Thank you very much 💯 |
The normal listing displays ip addresses of connections directly made to the server, so if you are connecting to the vps using SSH your ip will also be listed on that list, that is why the cloudflare servers are listed because they are making direct connections to your server. On the other side the cloudflare ip list displays real user ip's of people indirectly connecting to the server using cloudflare reverse proxy servers, so the information displayed should be correct. (By the way I commit a change to hide the reading from file... message thrown by tcpdump when using the -v flag).
You can try adding the cloudflare ip's (103.21.244.0/22, 103.22.200.0/22, 103.31.4.0/22, etc...) on your /etc/ddos/ignore.ip.list file, and just in case you should add your vps ip to that list also (just in case so the server doesn't bans itself, since I'm not sure if it is retrieving its own ip properly). Also out of curiosity how much time the server took to ban you when you launched the hulkdos test? Maybe I can remove the experimental message from the readme file :) |
Took around 2~3seconds after the surge of Cloudflare IPs (not yet whitelisted)
The default is DAEMON_FREQ=5, can it be lowered, or it will have performance impact? note: i think i didnt see this before... Thanks again |
that is multiplied by 2 to get 10 seconds total in order to give tcpdump enough time to collect data that can be analyzed, too little time I think would prevent enough data recollection to detect an attack. But yes, you can lower the daemon to 3 seconds interval so tcpdump will rotate every 6 seconds, you can try that and report back.
That was the installer? I need more details, in any case I will not be working until Sunday or Saturday late night have a nice day! |
…o work correctly as reported on issue #59.
uninstall.sh .. im using centos7 and didnt remember seeing that on my first uninstall. other than that, this issue is now solved, thank you very much |
Since this seems to be working I will close the issue, by they way make sure to delete the pcap files you shared earlier to keep your server IP private. |
hi jgmdev,
I installed this on centos 7 and when i tried to simulate ddos in my server/site, the ddos -v lists the various Cloudflare IPs as the attacker, and the connection count range from ~1 - ~100, effectively not blocking anything below the treshold.
Can you help how can this be fixed? The bulk of attack is from Cloudflare IP itself
The text was updated successfully, but these errors were encountered: