21

While learning some new things about iptables I can't through this. While I am trying to start, its saying as

 root@badfox:~# iptables -L -n -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
root@badfox:~# service iptables stop
iptables: unrecognized service
root@badfox:~# service iptables start
iptables: unrecognized service

Source: http://www.cyberciti.biz/tips/linux-iptables-examples.html

Why I am getting like this?

EDIT: So my firewall already started but why I am not getting the output as I mentioned in the link at source link in first workout.

Here is my output

root@badfox:~# sudo start ufw
start: Job is already running: ufw
root@badfox:~# iptables -L -n -v
Chain INPUT (policy ACCEPT 4882 packets, 2486K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 5500 packets, 873K bytes)
 pkts bytes target     prot opt in     out     source               destination         
root@badfox:~# 
5
  • 3
    iptables isnt a service, it runs all the time, the only true way to stop the firewall is to flush the rules to get everything empty and to ACCEPT. What exactly are you asking, though? By default there never are any rules configured.
    – Thomas Ward
    Jul 9, 2012 at 13:22
  • @LordofTime , click source link please
    – Raja G
    Jul 9, 2012 at 14:11
  • 1
    The above commands shows you don't have any user defined rule.If by that you mean you want to learn the firewall , implemented by the iptables , then follow this answer , though my answer but it has relevant links to get you started on iptables in Ubuntu. Also see its man page.And please edit the question to What exactly you are asking in simple words.
    – atenz
    Jul 9, 2012 at 14:23
  • 2
    Just a suggestion ,why don't you refer the Official iptables how to.
    – atenz
    Jul 9, 2012 at 15:24
  • No (the why don't ) , was just a way of suggesting , not to ask the reason or any other thing :D . Thanks , i will never try that One-liner again :D.
    – atenz
    Jul 9, 2012 at 15:50

2 Answers 2

33

The Uncomplicated Firewall or ufw is the configuration tool for iptables that comes by default on Ubuntu. So if you wanted to start or stop the ufw service, you'd have to do something like this

#To stop
$ sudo service ufw stop
ufw stop/waiting

#To start
$ sudo service ufw start
ufw start/running

About why you are not receiving the output as shown in the source. It clearly states there that the output you are receiving is for an inactive firewall, that is, no rules have been set. So try setting up some rules in iptables. Here's the Ubuntu Wiki on iptables that shows you how to set, edit them and such.

6
  • thanks for the answer .I have added some more information after EDIT . please look at that ,:)
    – Raja G
    Jul 9, 2012 at 14:57
  • 2
    To be able to see the rules you will have to insert rules ,read the Link entirely as #4: Insert Firewall Rules there.
    – atenz
    Jul 9, 2012 at 15:16
  • 1
    @imwrng Updated answer. And I agree with tjybba :) Jul 9, 2012 at 15:18
  • 1
    @imwrng Most welcome :) Jul 9, 2012 at 15:49
  • 1
    I would like to say ufw is just a configuration tool, not actually a firewall. Jul 8, 2016 at 12:32
3

the service command works on RedHat-based systems with iptables very well, even on Centos 7, which has adopted systemd.

So if Debian-based systems don't consider iptables a service per se, it still might be thought of as one. And the command "service iptables restart" is actually very useful, especially when you want iptables to restore the 'default' rule (meaning, to use the main script; in centos /etc/sysconfig/iptables, etc.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .