We help IT Professionals succeed at work.

How to make iptables to allow only certain IP's addresses

MatthewF
MatthewF asked
on
How do config iptables to allow only certain IP's addresses
Comment
Watch Question

What is it you are looking for? Are you looking to allow only certain ip addresses to access certain ports or services?

For example to allow ip's in the range of 192.168.1.100-192.168.1.200 to access ssh port 22,

iptables -A INPUT -p tcp --destination-port 22 -m iprange --src-range 192.168.1.100-192.168.1.200 -j ACCEPT

Here is a nice how-to for a start..

http://www.cyberciti.biz/tips/linux-iptables-how-to-specify-a-range-of-ip-addresses-or-ports.html
CERTIFIED EXPERT
Commented:
What is your Linux distribution?

Make sure iptables service is running.

Issue this commands
iptables -A INPUT  -s 192.168.0.254 -j ACCEPT
iptables -A INPUT -s 0/0 -j DROP 

Open in new window

Author

Commented:
I want to allow access to all protocol put only server ip addresses
CERTIFIED EXPERT

Commented:
If you see my rules, I am not restricting on protocols.  For all protocols as I said, don't mention the protocol part
check
iptables -L
for see the ip tables using

Explore More ContentExplore courses, solutions, and other research materials related to this topic.