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'm new at iptables. I'm trying to whitelist a IP. My server is behind a proxy and I'm getting refused connections since the server is thinking the proxy Ip is attacking it.

I have tried this below

/sbin/iptables -I INPUT -1 eth0 -s 111.11.1111.111 -j ACCEPT

The IP above is example only.

The OS is Ubuntu 11.10

I was wondering if that's the correct way to add it. I also don't know how to save it. I guess every time you reboot you have to add it. I was wondering what the command was to save it so I don't have to keep adding it.

share|improve this question
1  
After rebooting, what is the output of iptables -n -L? Are the lists empty? If so, then you shouldn't need to add a rule to accept. If the list is not empty, then you already have something managing your firewall, figure out what it is. –  Zoredache Feb 21 '12 at 23:54

1 Answer 1

Your iptables command is nearly correct, with a few exceptions:

  • The -I option means Insert, which requires an additional argument to specify where in the rule list the new rule should appear. For example -I INPUT 1
  • I believe you wanted -i instead of -1 to specify and input interface specification.
  • (optional) You've allowed all traffic, on any port, from this proxy system. You probably want to specify a protocol and/or port. Such as -p tcp --dport 80, which means protocol TCP with a destination port (on the local system) of 80. This would allow HTTP traffic.

That all aside, Ubuntu uses a configuration tool called UFW (Uncomplicated Firewall). You'll probably want to take a look at some documentation for how you can add custom iptables rules. Although, you can use UFW directly to add a simple destination rule like this, with:

sudo ufw allow from 111.11.11.111 to any app apache

This assumes you're trying to allow access to apache. For other applications, you could try:

sudo ufw app list
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.