S
S
syxoi2016-04-25 11:57:39
linux
syxoi, 2016-04-25 11:57:39

iptables close all ports except some on a specific network interface?

Hi all!
We have: network interface tun0 ("internal" network), eth0 - an external IP is assigned to it.
It is necessary to disable all ports on the eth0 network interface except for 1194 UDP and 22 TCP, respectively, tun0 cannot be touched.
I tried this:
iptables -A INPUT -i eth0 -j DROP
But connections are also blocked on tun0. Tell me, please, how to do everything right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2016-04-25
@syxoi

They are blocked not on tun0, but on eth0. You need to leave port 1194 open for your tunnel to work.

iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 1194 -j ACCEPT
iptables -A INPUT -i eth0 -j DROP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question