# iptables/firewall for systemd

## luciano

I upgraded to systemd a couple of months ago, following the gentoo systemd guide. However, I've been unable to find support for iptables (or any other firewall for that matter); the stable iptables version 1.4.20 doesn't appear to include init scripts for systemd. 

Also there is no replacement service discussed in the howto guide for iptables here http://wiki.gentoo.org/wiki/Systemd#Native_services . 

Any suggestions?

----------

## Hu

In openrc, the iptables init script is just a wrapper around calling iptables-restore to load rules at startup and iptables-save to save them to persistent storage at shutdown.  If no systemd service exists for it, one should be easy to write.  No processes are left running long term for systemd to manage.

----------

## 666threesixes666

mkultra@mkultra [ ~ ] $ locate iptables | grep service

/usr/portage/net-firewall/arno-iptables-firewall/files/arno-iptables-firewall.service

mkultra@mkultra [ ~ ] $ cat /usr/portage/net-firewall/arno-iptables-firewall/files/arno-iptables-firewall.service

```

[Unit]

Description=A secure stateful firewall for both single and multi-homed machine

Before=network.target

Wants=network.target

[Service]

Type=oneshot

ExecStart=/usr/sbin/arno-iptables-firewall start

ExecStop=/usr/sbin/arno-iptables-firewall stop

ExecReload=/usr/sbin/arno-iptables-firewall force-reload

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

```

and it looks like UFW has systemd service files.

mkultra@mkultra [ ~ ] $ cat /usr/lib64/systemd/system/ufw.service

```

[Unit]

Description=Uncomplicated Firewall

DefaultDependencies=no

Before=network.target sysinit.target

After=systemd-sysctl.service

ConditionPathExists=|/etc/ufw/ufw.conf

[Service]

Type=oneshot

RemainAfterExit=yes

ExecStart=/usr/share/ufw/ufw-init start

ExecStop=/usr/share/ufw/ufw-init stop

[Install]

WantedBy=multi-user.target

```

id probably go with ufw, i just got it up and going on my laptop i haven't tinkered with it with systemd yet....

https://wiki.gentoo.org/wiki/Ufw

----------

## luciano

Thanks for your replies. Based on your comments, I've open an enhancement request: https://bugs.gentoo.org/show_bug.cgi?id=501610

----------

