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

I have a ubuntu server that receives many ping requests from various other servers in the network. I would like to be able to proxy these requests. Using iptable rules I can see how to DROP or ACCEPT the requests but is there a way to redirect them? More specifically I'm looking for a way to conditionally respond to them. Maybe a little psudo code will help explain...

 if [ "$SourceIP" ==  "" ]; then
    #send response
 elif [ "$SourceIP" == "" ]; then
 elif [ "$SourceIP == "" ]; then
    sleep 20
    #send response

I know I can use iptable rules to drop and accept for specific ip addresses (the first two scenarios). But I need more control than that. I need to be able to put logic into when and if a response is given.

Is this possible?

Thanks for any ideas you can offer!

share|improve this question

As you have already realised, iptables can perform certain actions (drop/reject/accept) on certain conditions (IP/port/protocol/etc). You can have your iptables file organised in a similar way as to what you just described in your shell script example.

I think you can either operate on iptables/netfilter extensions/modules as to define actions for given scenarios (Rejects on certain IPs, accepts on others etc.), writing them in specific order (like in your shell script). I am not sure what exact actions you want to perform and at what conditions, but you may try checking for extensions here: Netfilter Extensions HOWTO as well as XTables-Addons

There was also a discussion on severfault how to introduce extra delays with tc, if you need those in place as well.

share|improve this answer

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.