Link to home
Create AccountLog in
Avatar of MatthewF
MatthewFFlag for Afghanistan

asked on

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

How do config iptables to allow only certain IP's addresses
Avatar of legolasthehansy

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 to access ssh port 22,

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

Here is a nice how-to for a start..
Avatar of farzanj
Flag of Canada image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MatthewF


I want to allow access to all protocol put only server ip addresses
If you see my rules, I am not restricting on protocols.  For all protocols as I said, don't mention the protocol part
iptables -L
for see the ip tables using