How To Block Ports With Iptables?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/block-ports-iptables/
PINTEREST
PINTEREST
INSTAGRAM

I have some ports open to the whole network. I can not stop services working on these ports. How can I block ports with iptables? To operate with iptables root credentials are needed.

Block Incoming Tcp Port 80

In this example we will block port 80 for incoming tcp connections.

  • -A INPUT specifies incoming connections
  • -p tcp for tcp protocol
  • -dport 80 to specify port no 80
  • -j DROP is the most important part which specifies action will be taken in this case we drop packet

Block Outgoing Tcp Port 22

In this example we will block port 22 for incoming tcp connections.

  • -A OUTPUT specifies outgoing connections
  • -p tcp for tcp protocol
  • -dport 22 to specify port no 22
  • -j DROP is the most important part which specifies action will be taken in this case we drop packet

List Iptables Rules

Now to make simple check we will list iptables rules

Save Iptables Rules

The rules we have created are stored in run time. After system restart they wil be lost. To save rules following command can be used.

LEARN MORE  Alignment of Security Function To Strategy, Goals and Mission

 

 

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/block-ports-iptables/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)