added a readme and cleaned up files
This commit is contained in:
parent
3c28023519
commit
d054ceee96
54
README.md
54
README.md
@ -0,0 +1,54 @@
|
|||||||
|
# IPSet and iptables Country Blocker
|
||||||
|
|
||||||
|
This repository contains a bash tool that utilizes ipset and iptables to block access from specific countries to your server. The tool is designed to improve server security by restricting access to IP addresses associated with countries you specify.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Utilizes ipset and iptables to block incoming traffic from specified countries.
|
||||||
|
- Multi-threaded implementation for improved performance.
|
||||||
|
- Simple installation and setup process.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
To use this tool, you need to ensure the following dependencies are installed on your system:
|
||||||
|
- ipset
|
||||||
|
- iptables
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. Clone this repository to your desired location:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://gitea.tofasthacker.ddnsfree.com/tofasthacker/ip_block.git
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Change into the repository directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ip_block
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Make the main script executable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x whitelist_us
|
||||||
|
chmod +x add_ipset
|
||||||
|
chmod +x toggle_block
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Run the tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./whitelist_us
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
This tool aims to provide an additional layer of security by blocking access from specific countries. However, it is important to note that IP geolocation is not always accurate, and IP addresses can be easily spoofed or routed through other countries. Therefore, this tool should be used as part of a comprehensive security strategy and not as the sole means of protection.
|
||||||
|
|
||||||
|
Please use this tool responsibly and adhere to the laws and regulations of your jurisdiction.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code in accordance with the terms of the license.
|
11
log.txt
11
log.txt
@ -1,11 +0,0 @@
|
|||||||
###### WHITELIST USA ######
|
|
||||||
root
|
|
||||||
Waiting 2 minutes
|
|
||||||
Creating ipset table
|
|
||||||
0
|
|
||||||
0
|
|
||||||
Download Finished!
|
|
||||||
Adding Networks to ipset ...
|
|
||||||
Whitelisting USA with iptables...
|
|
||||||
0
|
|
||||||
Done
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
echo "###### BLOCKING CHINA ######"
|
|
||||||
echo
|
|
||||||
|
|
||||||
ipset -N china hash:net -exist
|
|
||||||
ipset -F china
|
|
||||||
|
|
||||||
if [ -f "cn-aggregated.zone" ]
|
|
||||||
then
|
|
||||||
rm cn-aggregated.zone
|
|
||||||
fi
|
|
||||||
|
|
||||||
wget http://ipdeny.com/ipblocks/data/aggregated/cn-aggregated.zone
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
echo "Download Finished!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Adding Networks to ipset ..."
|
|
||||||
|
|
||||||
for net in `cat cn-aggregated.zone`
|
|
||||||
do
|
|
||||||
ipset -A china $net
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Blocking CN with iptables..."
|
|
||||||
iptables -I INPUT -m set --match-set china src -j DROP
|
|
||||||
echo "Done"
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
###### WHITELIST USA ######
|
|
||||||
root
|
|
||||||
Waiting 2 minutes
|
|
||||||
Creating ipset table
|
|
||||||
0
|
|
||||||
0
|
|
||||||
Download Failed: 1
|
|
||||||
Adding Networks to ipset ...
|
|
||||||
Whitelisting USA with iptables...
|
|
||||||
0
|
|
||||||
Done
|
|
23504
us-aggregated.zone
23504
us-aggregated.zone
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user