Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My server has multiple IPs,

and i have a service which listens to a port e.g. 88

Now i want,

when somebody from outside, wants to connect to the port, that he can only connect, to that port, if he connects to the ip but if he tries to connect to it should not react and it should look like that it dont exists and drops all connections.

Ok, than i need for that only allows a specific ip range outside connecters.

for example only 9.*.*.* can connect to that port and ip.

I'm using Centos. Thank you for your help.

share|improve this question
up vote 0 down vote accepted
iptables -A INPUT -s -d -p tcp -m tcp --dport 88 -j ACCEPT
iptables -A INPUT -d -p tcp -m tcp --dport 88 -j DROP
iptables -A INPUT -d -p tcp -m tcp --dport 88 -j DROP
share|improve this answer
iptables -A INPUT -s -d -p tcp --dport 88 -j ACCEPT

will restrict the source address (ie, who's making the connection) to, which is 9.*.*.* in your notation; it will restrict the destination address (ie, where they're connecting to) to; and it will only permit these for connections to the destination TCP port 88.

This assumes that (a) you already have a ruleset that forbids connections which aren't permitted, and (b) you get the rule in the right place in your ruleset. If you want more specific guidance than that, please amend your question with the output of iptables -L -n -v --line-number.

share|improve this answer
i marked the other answer, he was faster. but thank you for your answer :-) – user1015314 Mar 21 '12 at 12:11

Your Answer


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.