sudo apt-get install
iptables iptables-persistent
Create file
nano /etc/iptables/rules.v5
paste below lines into the file
##################################
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0]
#replace your ip with 1.1.1.1 -A INPUT -s 1.1.1.1/32 -j ACCEPT
# for outbound traffic
-A OUTPUT -d 1.1.1.1 -j ACCEPT
-A FORWARD -d 1.1.1.1 -j ACCEPT
-A INPUT -j DROP -A FORWARD -j DROP -A OUTPUT -j DROP COMMIT
###############################
Save file and close
Apply rules:-
iptables-restore < /etc/iptables/rules.v5
Now server can access only from 1.1.1.1
Comments
Post a Comment