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
  1. I have a website or perhaps an IRC server or whatever.
  2. The server keeps a list of all unique visitors (IP addresses).
  3. I have a panic button that, when activated, denies access to all visitors that are not already in the list.

This is to stop massive troll raids without shutting down the service for regulars.

What's the best way to implement this at a low level so that it's agnostic to the kind of server used? Like, some iptables voodoo or something?

Distro is Ubuntu.

share|improve this question

You can write a script that allows just them, and drops everything else, something like:

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT #to allow all established connections to continue, and to allow outgoing connections to get data back
iptables -A INPUT -i ethX -s {allowedIP#1} -j ACCEPT #allow first ip
iptables -A INPUT -i ethX -s {allowedIP#2} -j ACCEPT #..second
... #third and on
iptables -A INPUT -i ethX - -j DROP #drop everything else

Of course, if your IP list is very large, this becomes a resource hog.

share|improve this answer

/sbin/iptables -A INPUT   -m state --state NEW -i eth1  -p tcp --destination-port {YOURIRCPORT} -j DROP

Call it

To unlock create another similar script that has:

/sbin/iptables -D INPUT   -m state --state NEW -i eth1  -p tcp --destination-port {YOURIRCPORT} -j DROP

You can tweak it so you can use arguments to execute either rule.

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.