Why isn't the Iptables persistent service saving my changes?
up vote
12
down vote
favorite
I followed this tutorial to set up IP rules on ubuntu 12.04. Everything worked fine on setup -- but now I've made changes to the firewall that do not persist upon reboot. I do not understand why that is. Here is a demonstration of how I am using iptables-persistent. What am I doing wrong?
$ sudo service iptables-persistent start
* Loading iptables rules... * IPv4... * IPv6...
$ sudo iptables -L //shows a certain rule
$ iptables -D INPUT ... //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
$ sudo service iptables-persistent restart
* Loading iptables rules... * IPv4... * IPv6... [ OK ]
$ sudo iptables -L //rule is back
iptables iptables-persistent
add a comment |
up vote
12
down vote
favorite
I followed this tutorial to set up IP rules on ubuntu 12.04. Everything worked fine on setup -- but now I've made changes to the firewall that do not persist upon reboot. I do not understand why that is. Here is a demonstration of how I am using iptables-persistent. What am I doing wrong?
$ sudo service iptables-persistent start
* Loading iptables rules... * IPv4... * IPv6...
$ sudo iptables -L //shows a certain rule
$ iptables -D INPUT ... //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
$ sudo service iptables-persistent restart
* Loading iptables rules... * IPv4... * IPv6... [ OK ]
$ sudo iptables -L //rule is back
iptables iptables-persistent
I'm noticing theiptables -D INPUT
rule isn't insudo
are you sure it's actually reporting a success? Does the behavior change if you do run it withinsudo
?
– Bratchley
Apr 21 '14 at 16:29
add a comment |
up vote
12
down vote
favorite
up vote
12
down vote
favorite
I followed this tutorial to set up IP rules on ubuntu 12.04. Everything worked fine on setup -- but now I've made changes to the firewall that do not persist upon reboot. I do not understand why that is. Here is a demonstration of how I am using iptables-persistent. What am I doing wrong?
$ sudo service iptables-persistent start
* Loading iptables rules... * IPv4... * IPv6...
$ sudo iptables -L //shows a certain rule
$ iptables -D INPUT ... //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
$ sudo service iptables-persistent restart
* Loading iptables rules... * IPv4... * IPv6... [ OK ]
$ sudo iptables -L //rule is back
iptables iptables-persistent
I followed this tutorial to set up IP rules on ubuntu 12.04. Everything worked fine on setup -- but now I've made changes to the firewall that do not persist upon reboot. I do not understand why that is. Here is a demonstration of how I am using iptables-persistent. What am I doing wrong?
$ sudo service iptables-persistent start
* Loading iptables rules... * IPv4... * IPv6...
$ sudo iptables -L //shows a certain rule
$ iptables -D INPUT ... //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
$ sudo service iptables-persistent restart
* Loading iptables rules... * IPv4... * IPv6... [ OK ]
$ sudo iptables -L //rule is back
iptables iptables-persistent
iptables iptables-persistent
edited Apr 21 '14 at 16:12
asked Apr 21 '14 at 15:59
bernie2436
2,000153855
2,000153855
I'm noticing theiptables -D INPUT
rule isn't insudo
are you sure it's actually reporting a success? Does the behavior change if you do run it withinsudo
?
– Bratchley
Apr 21 '14 at 16:29
add a comment |
I'm noticing theiptables -D INPUT
rule isn't insudo
are you sure it's actually reporting a success? Does the behavior change if you do run it withinsudo
?
– Bratchley
Apr 21 '14 at 16:29
I'm noticing the
iptables -D INPUT
rule isn't in sudo
are you sure it's actually reporting a success? Does the behavior change if you do run it within sudo
?– Bratchley
Apr 21 '14 at 16:29
I'm noticing the
iptables -D INPUT
rule isn't in sudo
are you sure it's actually reporting a success? Does the behavior change if you do run it within sudo
?– Bratchley
Apr 21 '14 at 16:29
add a comment |
3 Answers
3
active
oldest
votes
up vote
35
down vote
accepted
iptables-persistent
does not work that way. Restarting the iptables-persistent
"service" does not capture the current state of the iptables and save it; all it does is reinstate the iptables rules that were saved when the package was last configured.
To configure iptables-persistent
, you need to tell it about your current iptables ruleset.
One way to accomplish that is as follows:
iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6
Or, equivalently, the iptables-persistent
package also provides the following:
dpkg-reconfigure iptables-persistent
(You will need to answer yes to the questions about whether to save the rules.)
After that, the next time iptables-persistent
is started/restarted, the iptables rulesets you expect will be loaded.
add a comment |
up vote
5
down vote
Very simple way to save the current iptables rules is to use the command:
sudo service netfilter-persistent save
Using the above, which works at least in Ubuntu after installing the netfilter-persistent
(and iptables-persistent
) package, there is no need to run manually the iptables commands or to reconfigure the package (as suggested by even the accepted Answer above).
Is itsudo service netfilter-persistent save
orsudo service netfilter-persistent save .
? (Dot at the end.)
– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
add a comment |
up vote
3
down vote
$ iptables ... DROP //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
That's not what DROP
means or does. From man iptables
:
...the special values ACCEPT, DROP, QUEUE or RETURN. ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means...
So what you've done is add a new rule. It may effectively supersede any number of other rules, but those rules still exist.
When checking stuff like this (your iptables -L
output), I would feed it though grep "string unique to this rule"
rather than use your eyes. It's easier and faster to do, and less error prone.
iptables -L | grep "some unique string"
If you want to delete a rule, use the -D
switch; the man page describes two forms of this:
-D, --delete chain rule-specification
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking aboutiptables
is confusing as hell.
– Bratchley
Apr 21 '14 at 16:27
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
35
down vote
accepted
iptables-persistent
does not work that way. Restarting the iptables-persistent
"service" does not capture the current state of the iptables and save it; all it does is reinstate the iptables rules that were saved when the package was last configured.
To configure iptables-persistent
, you need to tell it about your current iptables ruleset.
One way to accomplish that is as follows:
iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6
Or, equivalently, the iptables-persistent
package also provides the following:
dpkg-reconfigure iptables-persistent
(You will need to answer yes to the questions about whether to save the rules.)
After that, the next time iptables-persistent
is started/restarted, the iptables rulesets you expect will be loaded.
add a comment |
up vote
35
down vote
accepted
iptables-persistent
does not work that way. Restarting the iptables-persistent
"service" does not capture the current state of the iptables and save it; all it does is reinstate the iptables rules that were saved when the package was last configured.
To configure iptables-persistent
, you need to tell it about your current iptables ruleset.
One way to accomplish that is as follows:
iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6
Or, equivalently, the iptables-persistent
package also provides the following:
dpkg-reconfigure iptables-persistent
(You will need to answer yes to the questions about whether to save the rules.)
After that, the next time iptables-persistent
is started/restarted, the iptables rulesets you expect will be loaded.
add a comment |
up vote
35
down vote
accepted
up vote
35
down vote
accepted
iptables-persistent
does not work that way. Restarting the iptables-persistent
"service" does not capture the current state of the iptables and save it; all it does is reinstate the iptables rules that were saved when the package was last configured.
To configure iptables-persistent
, you need to tell it about your current iptables ruleset.
One way to accomplish that is as follows:
iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6
Or, equivalently, the iptables-persistent
package also provides the following:
dpkg-reconfigure iptables-persistent
(You will need to answer yes to the questions about whether to save the rules.)
After that, the next time iptables-persistent
is started/restarted, the iptables rulesets you expect will be loaded.
iptables-persistent
does not work that way. Restarting the iptables-persistent
"service" does not capture the current state of the iptables and save it; all it does is reinstate the iptables rules that were saved when the package was last configured.
To configure iptables-persistent
, you need to tell it about your current iptables ruleset.
One way to accomplish that is as follows:
iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6
Or, equivalently, the iptables-persistent
package also provides the following:
dpkg-reconfigure iptables-persistent
(You will need to answer yes to the questions about whether to save the rules.)
After that, the next time iptables-persistent
is started/restarted, the iptables rulesets you expect will be loaded.
answered Apr 21 '14 at 16:32
Steven Monday
1,143911
1,143911
add a comment |
add a comment |
up vote
5
down vote
Very simple way to save the current iptables rules is to use the command:
sudo service netfilter-persistent save
Using the above, which works at least in Ubuntu after installing the netfilter-persistent
(and iptables-persistent
) package, there is no need to run manually the iptables commands or to reconfigure the package (as suggested by even the accepted Answer above).
Is itsudo service netfilter-persistent save
orsudo service netfilter-persistent save .
? (Dot at the end.)
– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
add a comment |
up vote
5
down vote
Very simple way to save the current iptables rules is to use the command:
sudo service netfilter-persistent save
Using the above, which works at least in Ubuntu after installing the netfilter-persistent
(and iptables-persistent
) package, there is no need to run manually the iptables commands or to reconfigure the package (as suggested by even the accepted Answer above).
Is itsudo service netfilter-persistent save
orsudo service netfilter-persistent save .
? (Dot at the end.)
– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
add a comment |
up vote
5
down vote
up vote
5
down vote
Very simple way to save the current iptables rules is to use the command:
sudo service netfilter-persistent save
Using the above, which works at least in Ubuntu after installing the netfilter-persistent
(and iptables-persistent
) package, there is no need to run manually the iptables commands or to reconfigure the package (as suggested by even the accepted Answer above).
Very simple way to save the current iptables rules is to use the command:
sudo service netfilter-persistent save
Using the above, which works at least in Ubuntu after installing the netfilter-persistent
(and iptables-persistent
) package, there is no need to run manually the iptables commands or to reconfigure the package (as suggested by even the accepted Answer above).
edited Nov 23 at 22:25
answered Nov 3 '16 at 16:53
OpenITeX
15116
15116
Is itsudo service netfilter-persistent save
orsudo service netfilter-persistent save .
? (Dot at the end.)
– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
add a comment |
Is itsudo service netfilter-persistent save
orsudo service netfilter-persistent save .
? (Dot at the end.)
– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
Is it
sudo service netfilter-persistent save
or sudo service netfilter-persistent save .
? (Dot at the end.)– Tomasz
Feb 27 at 15:15
Is it
sudo service netfilter-persistent save
or sudo service netfilter-persistent save .
? (Dot at the end.)– Tomasz
Feb 27 at 15:15
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
Thanks for noting that, the correct command is w/o the dot at the end of line. Corrected the Answer accordingly.
– OpenITeX
Nov 23 at 22:26
add a comment |
up vote
3
down vote
$ iptables ... DROP //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
That's not what DROP
means or does. From man iptables
:
...the special values ACCEPT, DROP, QUEUE or RETURN. ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means...
So what you've done is add a new rule. It may effectively supersede any number of other rules, but those rules still exist.
When checking stuff like this (your iptables -L
output), I would feed it though grep "string unique to this rule"
rather than use your eyes. It's easier and faster to do, and less error prone.
iptables -L | grep "some unique string"
If you want to delete a rule, use the -D
switch; the man page describes two forms of this:
-D, --delete chain rule-specification
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking aboutiptables
is confusing as hell.
– Bratchley
Apr 21 '14 at 16:27
add a comment |
up vote
3
down vote
$ iptables ... DROP //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
That's not what DROP
means or does. From man iptables
:
...the special values ACCEPT, DROP, QUEUE or RETURN. ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means...
So what you've done is add a new rule. It may effectively supersede any number of other rules, but those rules still exist.
When checking stuff like this (your iptables -L
output), I would feed it though grep "string unique to this rule"
rather than use your eyes. It's easier and faster to do, and less error prone.
iptables -L | grep "some unique string"
If you want to delete a rule, use the -D
switch; the man page describes two forms of this:
-D, --delete chain rule-specification
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking aboutiptables
is confusing as hell.
– Bratchley
Apr 21 '14 at 16:27
add a comment |
up vote
3
down vote
up vote
3
down vote
$ iptables ... DROP //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
That's not what DROP
means or does. From man iptables
:
...the special values ACCEPT, DROP, QUEUE or RETURN. ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means...
So what you've done is add a new rule. It may effectively supersede any number of other rules, but those rules still exist.
When checking stuff like this (your iptables -L
output), I would feed it though grep "string unique to this rule"
rather than use your eyes. It's easier and faster to do, and less error prone.
iptables -L | grep "some unique string"
If you want to delete a rule, use the -D
switch; the man page describes two forms of this:
-D, --delete chain rule-specification
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
$ iptables ... DROP //command successfully drops the rule
$ sudo iptables -L //shows rule has been deleted
That's not what DROP
means or does. From man iptables
:
...the special values ACCEPT, DROP, QUEUE or RETURN. ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means...
So what you've done is add a new rule. It may effectively supersede any number of other rules, but those rules still exist.
When checking stuff like this (your iptables -L
output), I would feed it though grep "string unique to this rule"
rather than use your eyes. It's easier and faster to do, and less error prone.
iptables -L | grep "some unique string"
If you want to delete a rule, use the -D
switch; the man page describes two forms of this:
-D, --delete chain rule-specification
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
answered Apr 21 '14 at 16:06
goldilocks
61.1k13150204
61.1k13150204
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking aboutiptables
is confusing as hell.
– Bratchley
Apr 21 '14 at 16:27
add a comment |
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking aboutiptables
is confusing as hell.
– Bratchley
Apr 21 '14 at 16:27
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
sorry that was unclear. I am using the -D option to DROP a rule. See the change above
– bernie2436
Apr 21 '14 at 16:13
2
2
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking about iptables
is confusing as hell.– Bratchley
Apr 21 '14 at 16:27
-D
stands for "delete" not "DROP" Using the term "DROP" to mean anything other than a jump target when talking about iptables
is confusing as hell.– Bratchley
Apr 21 '14 at 16:27
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f125833%2fwhy-isnt-the-iptables-persistent-service-saving-my-changes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm noticing the
iptables -D INPUT
rule isn't insudo
are you sure it's actually reporting a success? Does the behavior change if you do run it withinsudo
?– Bratchley
Apr 21 '14 at 16:29