64 lines
1.1 KiB
Plaintext
64 lines
1.1 KiB
Plaintext
|
|
## - Create a systemd service
|
|
## -
|
|
|
|
# IPv4
|
|
#
|
|
cat <<EOF >> /etc/systemd/system/ipt-firewall.service
|
|
[Unit]
|
|
Description=IPv4 Firewall with iptables
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
ExecStart=/usr/local/sbin/ipt-firewall-server start
|
|
ExecStop=/usr/local/sbin/ipt-firewall-server stop
|
|
User=root
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# IPv6
|
|
#
|
|
cat <<EOF >> /etc/systemd/system/ip6t-firewall.service
|
|
[Unit]
|
|
Description=IPv6 Firewall with ip6tables
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
ExecStart=/usr/local/sbin/ip6t-firewall-server start
|
|
ExecStop=/usr/local/sbin/ip6t-firewall-server stop
|
|
User=root
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
|
|
## - Eanable script (for autostart at boot time)
|
|
## -
|
|
systemctl enable ipt-firewall.service
|
|
systemctl enable ip6t-firewall.service
|
|
|
|
## - Reload systemd configuration
|
|
## -
|
|
systemctl daemon-reload
|
|
|
|
|
|
## - Start Services
|
|
## -
|
|
systemctl start ipt-firewall
|
|
systemctl start ip6t-firewall
|
|
|
|
|
|
## - Add to /etc/rc.local
|
|
## -
|
|
## - sleep 2
|
|
## - systemctl restart ipt-firewall || /bin/true
|
|
## - systemctl restart ip6t-firewall || /bin/true
|
|
|