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

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" ==  "192.168.1.5" ]; then
    #send response
 elif [ "$SourceIP" == "192.168.1.6" ]; then
    #drop
 elif [ "$SourceIP == "192.168.1.7" ]; then
    sleep 20
    #send response
 fi

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

1 Answer 1

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

 
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.