Go Back   Dreambox, Receivers, Television Forum, High definition TV, 3DTV,CCcam, Gbox, Servers, Exchange, TV, LCD, Mobile > Cardsharing Tutorials > General Tutorials




Reply
 
LinkBack Thread Tools Display Modes
Old 01-05-2012, 10:51 AM   #1
Senior Member
 
Join Date: Dec 2011
Posts: 140
Default How to block IP's in different country's

Hello,

Does anyone know how i can block in my linux server IP's from different country's so they can't get acces to my server ?


Thanks in advance


samstar is offline   Reply With Quote
Old 01-05-2012, 05:27 PM   #2
Administrator
 
cardsharing's Avatar
 
Join Date: Jan 2009
Posts: 1,680
Default

you can use iptables to block some ips
do you want to bann all ips from a country?
cardsharing is online now   Reply With Quote
Old 01-05-2012, 08:00 PM   #3
Senior Member
 
Join Date: Dec 2011
Posts: 140
Default

Quote:
Originally Posted by cardsharing View Post
you can use iptables to block some ips
do you want to bann all ips from a country?

Yes, to block all ip's from a whole country. Well, i need to block all ip's, only the Belgium and France ip's are allowed. Any help please ?
samstar is offline   Reply With Quote
Old 01-05-2012, 09:01 PM   #4
Administrator
 
cardsharing's Avatar
 
Join Date: Jan 2009
Posts: 1,680
Default

Hi
http://ipinfodb.com/ip_country_block.php#blocklist

Choose the country for the list , save the file blocklist.txt
Upload blocklist.txt on your linux server in a directory

create a new file called banip with this content

### SCRIPT ###
#!/bin/sh
cat blocklist.txt | awk '{print $1;}' | sort | uniq | while read a; do iptables -A INPUT -s $a -j DROP;done
sleep 1
/sbin/iptables-save > /etc/sysconfig/iptables
chmod go-r /etc/sysconfig/iptables
/sbin/service iptables restart


upload banip file in the same directory with blocklist.txt , set chmod 755 for banip and then run the banip file
I really recomand you to make this job only if you know some minimum linux details, if not you can fault your server
cardsharing is online now   Reply With Quote
Old 01-05-2012, 10:11 PM   #5
Senior Member
 
Join Date: Dec 2011
Posts: 140
Default

Thanks a lot admin, you're the best. Its working, now i don't have a lot of warning.txt in my /tmp folde with "Login Failed..."

Thanks a lot mate. There is 1 thing i want to ask about that script, do i need to run it only 1 time or everyday or once a week or...?

Thanks again
samstar is offline   Reply With Quote
Old 02-02-2012, 11:06 PM   #6
Senior Member
 
Join Date: Feb 2009
Posts: 306
Default fail2ban??

Quote:
Originally Posted by cardsharing View Post
Hi
http://ipinfodb.com/ip_country_block.php#blocklist

Choose the country for the list , save the file blocklist.txt
Upload blocklist.txt on your linux server in a directory

create a new file called banip with this content

upload banip file in the same directory with blocklist.txt , set chmod 755 for banip and then run the banip file
I really recomand you to make this job only if you know some minimum linux details, if not you can fault your server

Hi Cardsharing,
Another question about your banip script file. I have just wanted to use your script as fail2ban code. "Blocklist file" includes only country ip numbers. On the contrary, "log warnings" file includes numeric and alpha-numeric strings.
Do you think if that works out as fail2ban code when I make some changes in CCcam.cfg file and below script?

In CCcam.cfg file:
log warnings: /tmp/warnings.txt

In Script:

Code:
### SCRIPT ###
#!/bin/sh
cat warnings.txt | awk '{print $1;}' | sort | uniq | while read a; do iptables -A INPUT -s $a -j DROP;done
sleep 1
/sbin/iptables-save > /etc/sysconfig/iptables
chmod go-r /etc/sysconfig/iptables
/sbin/service iptables restart
I certainly will put those files under the same folder and then run.

Thanks in advance
Tinkerbell
tinkerbell is offline   Reply With Quote
Reply




Tags
block, country, ip

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are On



All times are GMT +1. The time now is 11:09 AM.

vBSkinworks Design

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.