Solved

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

Posted on 2012-03-13
5
391 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 475 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

749 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