iptables-restore not working as described in "Securing Your

I've just rebuilt a Debian 7.3 server. I'm working through the instructions in the "Securing Your Server" https://library.linode.com/securing-your-server page and copied and pasted the rules as shown into an /etc/iptables.firewall.rules file. When I run the command "sudo iptables-restore < /etc/iptables.firewall.rules", I always get this error:

iptables-restore v1.4.14: no command specified

Error occurred at line: 33

Line 33 is the last line in the file, "COMMIT".

I copied and pasted the file from the web page into sublimetext editor and double-checked to ensure there aren't any bad characters in the file. The permissions for the file are 644 and it's owned by root:root.

Has something changed to make this document out-of-date? I went through this process early last December and I was able to create this file and then create the firewall rules without any problems.

Thanks!

2 Replies

I discovered the solution. For a reason I don't understand, there needs to be a blank line after the final line that contains the "COMMIT" statement. Copying and pasting the file's contents from the web page won't necessarily add a blank line.

@rlfprog:

I discovered the solution. For a reason I don't understand, there needs to be a blank line after the final line that contains the "COMMIT" statement. Copying and pasting the file's contents from the web page won't necessarily add a blank line.
True indeed. Thanks for that! The extra line did the trick.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct