Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Iptables forgetting my rules


  • Please log in to reply
3 replies to this topic

#1 The Pugilist

The Pugilist

  • Members
  • 826 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Local time:09:39 PM

Posted 29 June 2011 - 10:25 AM

Hello all,

I have been attempting to setup a few basic iptables rules on my server (which is running ubuntu 11.04 server x64). The problem I am running into is after setting up the rules and testing them to make sure they work, if/when i reboot the server those rules are then reset.

Here are the steps I have taken.

To keep things simple, to start I closed port 22 on the adapter 'eth0'
# /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 22 -j DROP
# iptables-save

After doing this I queried the list of rules:
# iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       tcp  --  anywhere             anywhere            tcp dpt:ssh 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination      

After testing SSH access over my local network I could not connect so I know it works. After restarting the same 'iptables -L' command returns an empty list and I can still connect via ssh over my local network. Im not sure what I am doing wrong here. Your insight is much appreciated

EDIT:had the syntax wrong for one of the commands

Edited by The Pugilist, 29 June 2011 - 10:38 AM.

//Dave

BC AdBot (Login to Remove)

 


#2 Keith1

Keith1

  • Members
  • 504 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Hamilton, Ohio
  • Local time:08:39 PM

Posted 29 June 2011 - 01:54 PM

I know very little about this, so I'll ask. Should the line iptables-save contain a file name where to save the rules to?

#3 The Pugilist

The Pugilist
  • Topic Starter

  • Members
  • 826 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Local time:09:39 PM

Posted 29 June 2011 - 02:12 PM

In doing a little more research I guess it should. the manual for iptables-save returns this as a description:

iptables-save dump iptables rules to stdout


This is contrary to the guide I was reading on the subject which used it without any arguments at all (as I did). I had just assumed this command would update the iptables configuration but I guess not... Perhaps I have to dump the rules to a flat file to somehow load it everytime the computer boots? :wacko:
//Dave

#4 Keith1

Keith1

  • Members
  • 504 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Hamilton, Ohio
  • Local time:08:39 PM

Posted 29 June 2011 - 03:10 PM

I think this is what you are looking for - hope this helps -


http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-iptables-saving.html




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users