Categories

Iptables. How to open a port to one ore more specific IP

Written by Guillermo Garron .
Date: 2013-01-28 02:31:10 +0000

Sometimes you need to open a port on your server, you want it to be recheable only from specific IP address, you can use Iptables for this:

iptables -I INPUT -p tcp -s 10.1.1.2 --dport 22 -j ACCEPT

In that case, you are opening ssh port only to IP 10.1.1.2, if you need to open DNS for your internal network.

iptables -I INPUT -p udp -s 10.1.0.0/16 --dport 53 -j ACCEPT

Once you have them added and opened for those IPs, you need to close the door for the rest of IPs

iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 22 -j DROP
iptables -I INPUT -p udp -s 0.0.0.0/0 --dport 53 -j DROP

comments powered by Disqus

Bio.

My name is Guillermo Garron. I am telecommunications engineer from Bolivia

I like technology a lot, and this site is mainly dedicated to that

Social feeds

rss | twitter | email | google+