S
S
Stanislav Smirnov2015-10-19 14:49:31
linux
Stanislav Smirnov, 2015-10-19 14:49:31

How to close everything via iptables without losing access to the virtual machine?

Good to all, the question is the following, is it necessary to tightly clog everything except certain services on a virtual server?
The following code, if you believe the mans from the Internet, blocks everything that has no rules:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

So first you need to create rules for the same ssh so as not to lose access and then set these policies?
What other rules should be added to iptales so as not to lose access via ssh? It turns out that all settings are lost when the system is rebooted? Without exception? I just think for the time of experiments to protect myself with a timer to reboot the machine.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Fedoseev, 2015-10-19
@martin74ua

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
service iptables save
something like this

V
Vlad Zhivotnev, 2015-10-19
@inkvizitor68sl

iptables-save > file
edit file
cat file | iprables-restore
Well, check that you will be able to reboot the server to reset the settings, if anything. When all the rules are checked, add them to autoload in any way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question