0

I have changed ssh default port to 2020, And add iptable rule in order to allow incoming traffic on that port using below command.

iptables -A INPUT -p tcp -m tcp --dport 2020 -j ACCEPT

And i would like to block all other ports on the server. And use below command after allowing ssh. All session are closed. How can i fix it.

iptables -P INPUT DROP

iptables -P OUTPUT DROP

blaCkninJa
  • 445
  • 2
  • 11
  • 22

1 Answers1

4

You may need to enable OUTPUT

    iptables -P INPUT ACCEPT
    iptables -P OUTPUT ACCEPT
    iptables -F
    iptables -A INPUT -i lo -j ACCEPT
    iptables -A INPUT -p tcp -m tcp --dport 2020 -j ACCEPT
    iptables -A OUTPUT -p tcp -m tcp --sport 2020 -j ACCEPT
    iptables -P INPUT DROP
    iptables -P OUTPUT DROP
Abdul Ahad
  • 826
  • 8
  • 16