A
A
Alexander777xx2018-06-21 12:36:31
linux
Alexander777xx, 2018-06-21 12:36:31

How to close all ports in iptables except 25565?

Hello! I have a game server and on it it is necessary to close absolutely all ports except 25565 in iptables.
25565 on it. Port 25565 is needed to connect players to the server. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-06-21
@Alexander777xx

iptables -A INPUT -p tcp -m tcp -m multiport ! --dports 25565 -j DROP

before you add this rule, remember that you are connected to the server via ssh through port 22.
The site probably works on 80/443.
And ftp to access the site at 21, if any.

C
cssman, 2018-06-21
@cssman

sudo iptables -A INPUT -p tcp -s subnet/mask --dport 25565 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 25565 -m conntrack --ctstate ESTABLISHED -j ACCEPT
PS subnet/mask - address or address pool of your
PPS server if you like, at the end you can put an explicit deny all: sudo iptables -P INPUT DROP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question