Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-13
5
Medium Priority
?
403 Views
Last Modified: 2012-03-14
How do config iptables to allow only certain IP's addresses
0
Comment
Question by:MatthewF
5 Comments
 
LVL 11

Expert Comment

by:legolasthehansy
ID: 37716506
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
0
 
LVL 31

Accepted Solution

by:
farzanj earned 1900 total points
ID: 37716519
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

0
 

Author Comment

by:MatthewF
ID: 37717330
I want to allow access to all protocol put only server ip addresses
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37718007
If you see my rules, I am not restricting on protocols.  For all protocols as I said, don't mention the protocol part
0
 

Expert Comment

by:dubeyrupesh
ID: 37718442
check
iptables -L
for see the ip tables using
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question