P
P
PlayBoyXXX2021-03-21 18:09:50
iptables
PlayBoyXXX, 2021-03-21 18:09:50

How to close connections from all IPs, except for selected ones?

How to close connections from all IPs on VPS (Ubuntu 20.04) except for the ones I need. I tried myself, ended up closing ssh))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-03-21
@PlayBoyXXX

We assume that the firewall tables are empty, and there are no rules there.
We allow the necessary addresses:
iptables -A INPUT -i eth0 -p all -s 11.22.33.44 -j ACCEPT
iptables -A INPUT -i eth0 -p all -s 55.66.77.88 -j ACCEPT
now disable everything else
iptables -A INPUT -i eth0 -p all -j REJECT
You can also install ufw and master it, it's a handy and well-documented add-on to iptables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question