Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have to limit access to 8080 port and allow only some IPs and specific subnets. Is it possible, can you please help?

I enabled filtering for IPs but I couldn't find how to accept subnets?

sudo /sbin/iptables -N CHN_PNTS
sudo /sbin/iptables -A CHN_PNTS --src 182.10.10.109  -j ACCEPT  
sudo /sbin/iptables -A CHN_PNTS --src 182.20.35.110  -j ACCEPT 
sudo /sbin/iptables -A CHN_PNTS --src 182.20.55.15   -j ACCEPT 
sudo /sbin/iptables -A CHN_PNTS -j DROP 
sudo /sbin/iptables -I INPUT -m tcp -p tcp --dport 8080 -j CHN_PNTS

subnets that i want to accept;

182.24.137.0/24
182.24.138.0/23

Thanks
Erdal

share|improve this question
1  
--src 182.24.137.0/24 –  mtm Feb 18 '13 at 14:41

2 Answers 2

up vote 5 down vote accepted

You just use CIDR notation like in your question

sudo /sbin/iptables -A CHN_PNTS --src 182.24.137.0/24   -j ACCEPT
sudo /sbin/iptables -A CHN_PNTS --src 182.24.138.0/23   -j ACCEPT

Remember to place them before your

sudo /sbin/iptables -A CHN_PNTS -j DROP 

so that they are actioned correctly.

share|improve this answer
    
thanks, i tested it is working –  seyiterdal Feb 19 '13 at 13:15

Subnet specifications are acceptable in the source.

sudo /sbin/iptables -A CHN_PNTS --src 182.24.137.0/24 -j ACCEPT 
sudo /sbin/iptables -A CHN_PNTS --src 182.24.138.0/23 -j ACCEPT 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.