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 some rules that I would like to apply, I added the following

pre-up iptables-restore < /etc/iptablesRules

to /etc/network/interfaces so that they would automatically be applied.

After a reboot they are applied but after a few minutes they are being overwritten, by the default set?

Its an Ubuntu 12.04 vps.

Any ideas what could be causing this?

--- FIXED ---

After much mulling around it turns out there was a file /etc/sysconfig/firewall which was overwriting any rules set using the /network/interfaces as well as the iptables-persistent options.

So the lesson learned is that moving from one vps provider to another isn't exactly straight forward even if its the same OS.

share|improve this question
    
Do you use something like KVM inside that VPS? Because several such solutions come with their own set of iptables rules. Another option is that something related to dnsmasq adds rules. There is usually a pattern visible from the added rules. The only thing I can imagine is that in your case the tool that should merely add the rules actually empties the rule table before adding. –  0xC0000022L Feb 11 '13 at 17:46
    
I'm not sure, I got it from fasthosts and its the basic package so there aren't any addons like plesk etc if thats what you mean. What do you mean by pattern? –  cosmicsafari Feb 11 '13 at 17:48
    
Have you looked at all crontabs? What's the output of iptables -L -n -x before and after? –  Eric DANNIELOU Feb 11 '13 at 18:13
add comment

1 Answer

up vote 2 down vote accepted

I was looking into your problem and it looks like there's issue with your version of Ubuntu. More specifically dealing with how pre-up and Network Manager are working. It seems a lot of people have used the iptables-persistent package to successfully restore rules on start up with Ubuntu 12.04.

After installing iptables-persistent it will ask you if you'd like to save your current rules, or create a new rule set.

share|improve this answer
    
Looks like this is the way forward, cheers man. One thing though, is this a different program than just iptables and if so do i need to now disable the original iptables? –  cosmicsafari Feb 11 '13 at 19:00
1  
No, this is just a different "restore on start-up" method. Continue to use iptables as you normally would. –  mossy Feb 11 '13 at 19:02
    
Still having issues but i'm pretty certain its due to having to amend the rules slightly to work with the persistent version. –  cosmicsafari Feb 11 '13 at 19:31
    
Could you pastebin any errors that you are getting? –  mossy Feb 11 '13 at 19:33
    
Can't really see anything in syslog that looks relevant. I installed iptables-persistent and edited the /etc/iptables/rules.v4 as it suggest but it still reverting back to what I am assuming is the default –  cosmicsafari Feb 11 '13 at 20:02
show 1 more comment

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.