filmov
tv
Ubuntu: How to save rules of the iptables?
Показать описание
Ubuntu: How to save rules of the iptables?
The Question: I create the rules to iptables. But, when I restart the computer, the rules
don't work! How to save the rules on Ubuntu ?
----
The was problem solved!
do:
After of the write the commands iptables, do:
1. sudo su
3. In /etc/network/if-pre-up.d/iptables,put:
#!/bin/sh
exit 0
4. After, in /etc/network/if-post-down.d/iptables,put:
#!/bin/sh
fi
exit 0
5. After, give permission to the scripts:
sudo chmod +x /etc/network/if-post-down.d/iptables
sudo chmod +x /etc/network/if-pre-up.d/iptables
IptablesHowTo#Saving_iptables Good luck!
Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):
== This solution helped 38 people ==
The generic method of saving iptables rules is to use the command iptables-
save, which writes to stdout.
The output created by iptables-save can then by read on stdin by iptables-
restore. If on a server, without NetworkManager, a common approach is then to
use a pre-up command in /etc/network/interfaces.
iface eth0 inet static
....
If you are using NetworkManager it should be possible to run the same command
from a script created under /etc/NetworkManager/dispatcher.d/. In the https://
NetworkManager for more information.
Do note that the commands iptables, iptables-save and iptables-restore are IPv4
only. For IPv6 traffic the equivalent commands are ip6tables, ip6tables-save
and ip6tables-restore.
The Question: I create the rules to iptables. But, when I restart the computer, the rules
don't work! How to save the rules on Ubuntu ?
----
The was problem solved!
do:
After of the write the commands iptables, do:
1. sudo su
3. In /etc/network/if-pre-up.d/iptables,put:
#!/bin/sh
exit 0
4. After, in /etc/network/if-post-down.d/iptables,put:
#!/bin/sh
fi
exit 0
5. After, give permission to the scripts:
sudo chmod +x /etc/network/if-post-down.d/iptables
sudo chmod +x /etc/network/if-pre-up.d/iptables
IptablesHowTo#Saving_iptables Good luck!
Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):
== This solution helped 38 people ==
The generic method of saving iptables rules is to use the command iptables-
save, which writes to stdout.
The output created by iptables-save can then by read on stdin by iptables-
restore. If on a server, without NetworkManager, a common approach is then to
use a pre-up command in /etc/network/interfaces.
iface eth0 inet static
....
If you are using NetworkManager it should be possible to run the same command
from a script created under /etc/NetworkManager/dispatcher.d/. In the https://
NetworkManager for more information.
Do note that the commands iptables, iptables-save and iptables-restore are IPv4
only. For IPv6 traffic the equivalent commands are ip6tables, ip6tables-save
and ip6tables-restore.