LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2017, 02:18 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post How to restart iptables service in Debian?


Hello.
I'm using Debian 8.9 x64 and I want to know how can I restart iptables service?

Thank you.
 
Old 09-24-2017, 03:49 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
https://duckduckgo.com/?q=How+to+res...vice+in+Debian
you asked that very same question 1 year ago!
since it seems you were unable to solve it then, i guess one of the other search results will do you.

i have to ask this, without irony or sarcasm or trying to dis you, honest question:

do you suffer from some form of memory loss?

because if you do, you should tell us, it would help us to deal with your questions in a more appropriate manner.

Last edited by ondoho; 09-26-2017 at 12:35 AM.
 
2 members found this post helpful.
Old 09-24-2017, 03:59 AM   #3
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by ondoho View Post
https://duckduckgo.com/?q=How+to+res...vice+in+Debian
well f*ck me, you asked that very same question 1 year ago!
since it seems you were unable to solve it then, i guess one of the other search results will do you.

i have to ask this, without irony or sarcasm or trying to dis you, honest question:

do you suffer from some form of memory loss?

because if you do, you should tell us, it would help us to deal with your questions in a more appropriate manner.
In other Distro like Redhat you can do:
Code:
# yum install iptables-services
# service iptables stop
But I can't find it in Debian.
 
Old 09-24-2017, 04:04 AM   #4
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Try: ufw reload
(from clicking that ddg link)
 
Old 09-24-2017, 04:13 AM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
It's probably in iptables-persistent which uses the /etc/iptables/rules.v4 to make your (ipv4) rules persistent. Most times I have a script that sets my rules. Which clears all rules as the first step. But probably not best practices if connected to the internet on a high speed connection.

# iptables -t nat -F
# iptables -t nat -X
# iptables -F
# iptables -X

To flush and clear/delete ALL the rules. Well almost all, there's also mangle, filter, raw, and probably other tables besides nat. Although not used much in consumer land.
 
1 members found this post helpful.
Old 09-24-2017, 04:30 AM   #6
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
From the "Similar Threads" section at the bottom of all LQ posts,
https://www.linuxquestions.org/quest...6/#post5640900
all those iptables commands just store stuff in the kernel. There's no process (to restart)!!!
 
Old 09-24-2017, 05:10 AM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
My preference is still to set up a shell script which contains all iptables commands. Starting with disabling forwarding, setting the default policies for all tables and flush the tables. And then set up every rule.

Advantages of this approach are that every time you run you script you are assured to start from a fresh, known state. You can create variables to make you script more readable and make changes in one place if you have to change one setting in a lot of places. And you can build in conditionals.

There are many examples on the internet on how to create firewall scripts.

jlinkels
 
Old 09-24-2017, 05:57 AM   #8
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Thus, restart it is impossible?
 
Old 09-24-2017, 07:22 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
There is no "start" or "restart" in iptables. There is only the set of chains of rules held in memory. If you want to clear the chains, then clear the chains:

Code:
ip6tables --policy INPUT   ACCEPT;
ip6tables --policy OUTPUT  ACCEPT;
ip6tables --policy FORWARD ACCEPT;

ip6tables -Z; # zero counters
ip6tables -F; # flush (delete) rules
ip6tables -X; # delete all extra chains


iptables --policy INPUT   ACCEPT;
iptables --policy OUTPUT  ACCEPT;
iptables --policy FORWARD ACCEPT;

iptables -Z; # zero counters
iptables -F; # flush (delete) rules
iptables -X; # delete all extra chains
That will give you a blank slate with no rules in the kernel from there you can load new ones.
 
Old 09-25-2017, 01:09 AM   #10
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by Turbocapitalist View Post
There is no "start" or "restart" in iptables. There is only the set of chains of rules held in memory. If you want to clear the chains, then clear the chains:

Code:
ip6tables --policy INPUT   ACCEPT;
ip6tables --policy OUTPUT  ACCEPT;
ip6tables --policy FORWARD ACCEPT;

ip6tables -Z; # zero counters
ip6tables -F; # flush (delete) rules
ip6tables -X; # delete all extra chains


iptables --policy INPUT   ACCEPT;
iptables --policy OUTPUT  ACCEPT;
iptables --policy FORWARD ACCEPT;

iptables -Z; # zero counters
iptables -F; # flush (delete) rules
iptables -X; # delete all extra chains
That will give you a blank slate with no rules in the kernel from there you can load new ones.
"restart" is impossible in Debian?
 
1 members found this post helpful.
Old 09-25-2017, 01:45 AM   #11
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Yes, but there may be a iptables-restore<file here: https://wiki.debian.org/iptables
&more here: https://wiki.debian.org/DebianFirewall

Or you can 'forget' iptables entirely, and use ufw (I think!!!): https://www.digitalocean.com/communi...n-cloud-server

There is no concept of "reload/restart" for this kernel ip fw "table".
This *table* is not a process, so it cannot be stopped/started/restarted
(like a data array in memory cannot be ditto)

Last edited by !!!; 09-25-2017 at 01:55 AM.
 
Old 09-25-2017, 01:45 AM   #12
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
Quote:
Originally Posted by hack3rcon View Post
"restart" is impossible in Debian?
Drop all existing rules and set default routes to "ACCEPT"
Then load all existing rules from a script or some file.

That is what would be a "restart" for iptables.
 
Old 09-25-2017, 02:14 AM   #13
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by hack3rcon View Post
"restart" is impossible in Debian?
Correct. It is impossible in all Linux-based operating systems, not just Debian GNU/Linux. See the various comments above for different phrasing of the same message.

What are you really trying to do there?
 
2 members found this post helpful.
Old 09-25-2017, 01:12 PM   #14
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Quote:
Originally Posted by hack3rcon View Post
Thus, restart it is impossible?
It depends on how you define impossible or define restart. You can clear the rules, and unload the kernel modules (if they were compiled as modules). And then reload the modules. And reload the rules. Not really a restart though. And no simple or automated way to do that outside of a reboot.
 
Old 10-01-2017, 10:54 AM   #15
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by Shadow_7 View Post
It depends on how you define impossible or define restart. You can clear the rules, and unload the kernel modules (if they were compiled as modules). And then reload the modules. And reload the rules. Not really a restart though. And no simple or automated way to do that outside of a reboot.
But as I said, Redhat can do it!!! Am I wrong?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restart service or even reboot upon service stopping NotionCommotion Linux - Newbie 10 06-06-2017 11:56 AM
How can I restart iptables service? hack3rcon Debian 14 12-12-2016 07:11 AM
Cron service and oracle service stopped unexpectedly. Can't restart oracle. camron Linux - Newbie 6 06-10-2010 06:00 PM
iptables restart in Debian Etch apachenew Debian 6 09-11-2007 01:53 PM
How do I set the regulatory daemon to restart when I restart the network service? zahadumy Linux - Networking 0 11-05-2006 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration