Skip to content

Commit

Permalink
Update b.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedAp authored Jan 28, 2024
1 parent f639d77 commit 0d3ccb8
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions b.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
#!/bin/bash
clear
po=$(cat /etc/ssh/sshd_config | grep "^Port")
port=$(echo "$po" | sed "s/Port //g")

sudo apt install iptables ipset -y
sudo apt install libtext-csv-xs-perl libmoosex-types-netaddr-ip-perl iptables-persistent ipset -y

sudo wget -4 -O /root/iranip.txt https://raw.githubusercontent.com/HamedAp/Ssh-User-management/main/iranip.txt &
wait

iptables -F

ipset create whitelist hash:net
while read line; do ipset add whitelist $line; done < /root/iranip.txt
#iptables -A INPUT -p tcp --dport 22 -m set --match-set whitelist src -j ACCEPT
#iptables -A INPUT -p tcp --dport $port -m set --match-set whitelist src -j ACCEPT
#iptables -A INPUT -p tcp -m set --match-set whitelist src -j ACCEPT
#iptables -A INPUT -m set --match-set whitelist src -j ACCEPT
iptables -A OUTPUT -m set --match-set whitelist src -j DROP
#iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#iptables -I INPUT 1 -i lo -j ACCEPT
#iptables -A INPUT -j DROP
clear
ipset create shahaniran hash:net
ipset flush shahaniran
while read line; do ipset add shahaniran $line; done < /root/iranip.txt
#iptables -A OUTPUT -m set --match-set shahaniran src -j DROP
iptables -A OUTPUT -p tcp --dport 443 -m set --match-set shahaniran dst -j DROP
iptables -A OUTPUT -p tcp --dport 80 -m set --match-set shahaniran dst -j DROP
sudo iptables-save | sudo tee /etc/iptables/rules.v4
clear
echo "Blocked Iran Ip :)"

0 comments on commit 0d3ccb8

Please sign in to comment.