I have a Debian VPS on which I am trying to open some ports like 80, 443, etc. and here's what I've done:

Creating a test iptables file:

 editor /etc/iptables.test.rules

which has some basic rules:

-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

The problem is that I am getting the following error on all lines:

iptables-restore: line xx failed

and I need to enable these ports ASAP so what's wrong?

update: fixed everything but now I can't connect to the server via any form (put the address in a browser's address bar and go to it)

P.S.: I'm using this server for my home automation project as a mid point (An Android app issues the commands to the server which in turn issues it to the raspberry pi which controls the house and then the pi sends back a response of success or failure) - on which I'm trying to do the following:

1- enable some ports like 80 & 443 which I have enabled using iptables but still can't put the server's address in a browser's address bar and navigate to it.

2- how will the app communicate with the server noting that sign up & login will take place through the server as I'm right now have both the app & the Pi ready but separate (not connected together & I already know that they will communicate over HTTP but what I don't know is how ?)

  • line xx failed so which line is xx. That error usually is a number. That number tells you the line with the failure. If you gave us the actual error message, it would make it a lot easier to help you. – Zoredache May 11 '17 at 22:34
  • @Zoredache all the lines – user3090933 May 11 '17 at 23:24
  • Typically use a shell script so each line starts with the path to the iptables executable... /usr/bin/iptables -A INPUT -p tcp -dport 80 -j ACCEPT . Alternatively if you simply want to allow/disallow to ports use UFW and its super simple syntax of ufw allow ssh or ufw allow 80 etc – ivanivan May 12 '17 at 16:02
  • @ivanivan I used ufw allow ssh and still nothing happened – user3090933 May 13 '17 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.