Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

iptables / ip6tables on desktop with systemd - won't start

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
15 posts • Page 1 of 1
Author
Message
gordonp
Tux's lil' helper
Tux's lil' helper
Posts: 102
Joined: Mon May 23, 2005 3:08 pm

iptables / ip6tables on desktop with systemd - won't start

  • Quote

Post by gordonp » Mon Oct 31, 2016 10:05 pm

Hi -

I have two desktop machines, both running systemd (and dozens of others with Gentoo / RC init, but they're not the problem). On both these systemd desktkops, I found that iptables / ip6tables won't start :-( Here is what I see when I query about the status:

Code: Select all

# systemctl status iptables
● iptables.service - Store and restore iptables firewall rules
   Loaded: error (Reason: Invalid argument)
   Active: failed (Result: exit-code) since Mon 2016-10-31 14:13:46 PDT; 36min ago
 Main PID: 29236 (code=exited, status=203/EXEC)

Oct 31 14:13:46 pluto systemd[1]: Starting Packet Filtering Framework...
Oct 31 14:13:46 pluto systemd[1]: iptables.service: Main process exited, code=exited, status=203/EXEC
Oct 31 14:13:46 pluto systemd[1]: Failed to start Packet Filtering Framework.
Oct 31 14:13:46 pluto systemd[1]: iptables.service: Unit entered failed state.
Oct 31 14:13:46 pluto systemd[1]: iptables.service: Failed with result 'exit-code'.
Oct 31 14:13:54 pluto systemd[1]: iptables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Oct 31 14:38:09 pluto systemd[1]: iptables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Oct 31 14:41:03 pluto systemd[1]: iptables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Oct 31 14:41:15 pluto systemd[1]: iptables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
pluto system # systemctl status ip6tables
● ip6tables.service - Store and restore ip6tables firewall rules
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)
and for ip6tables, a little less wordy but about the same:

Code: Select all

# systemctl status ip6tables
● ip6tables.service - Store and restore ip6tables firewall rules
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Oct 31 14:50:22 pluto systemd[1]: ip6tables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Oct 31 14:52:29 pluto systemd[1]: ip6tables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
I've re-emerged both systemd and iptables. iptables is quite happy if I run it manually, as is ip6tables (by "happy" I mean that a list of rules is applied without complaint, and 'ip[6]tables -L -n' shows that my intended rules appear. Versions that I've re-merged are:

Code: Select all

[ebuild   R    ] sys-apps/systemd-226-r2:0/2::gentoo  USE="acl kdbus kmod lz4 pam policykit seccomp ssl (-apparmor) -audit -cryptsetup -curl -elfutils -gcrypt -gnuefi -http -idn -importd -lzma -nat -qrcode (-selinux) -sysv-utils {-test} -vanilla -xkb" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] net-firewall/iptables-1.4.21-r1::gentoo  USE="conntrack ipv6 -netlink -static-libs" 0 KiB
I have browsed /usr/lib64/systemd/system and looked at both iptables.service and ip6tables.service. I've even deleted these and allowed the re-emerge to re-create them, but to no avail :-( Both are bone-stock, and similar to each other:

Code: Select all

# cat iptables.service
[Unit]
Description=Store and restore iptables firewall rules

[Install]
Also=iptables-store.service
Also=iptables-restore.service
I've disabled and re-enabled the service, but that hasn't helped.

My Profile:

Code: Select all

default/linux/amd64/13.0/desktop/gnome/systemd *
What have I missed? What should I look at, to further figure out what's wrong?

Thank-you!
Top
eccerr0r
Watchman
Watchman
Posts: 10239
Joined: Thu Jul 01, 2004 6:51 pm
Location: almost Mile High in the USA
Contact:
Contact eccerr0r
Website

  • Quote

Post by eccerr0r » Tue Nov 01, 2016 1:12 am

Ok this is weird.

You should be able to just

Code: Select all

# systemctl enable iptables
# systemctl enable ip6tables
and next shutdowns it should save your settings, and next boots it will reload them.

Did you see this when you enabled them?

Code: Select all

Created symlink from /etc/systemd/system/shutdown.target.wants/iptables-store.service to /usr/lib64/systemd/system/iptables-store.service.
Created symlink from /etc/systemd/system/basic.target.wants/iptables-restore.service to /usr/lib64/systemd/system/iptables-restore.service.
It's actually iptables-store.service and iptables-restore.service that does the dirty work.
Intel Core i7 2700K/Radeon Firepro W2100/24GB DDR3/800GB SSD
What am I supposed watching?
Top
gordonp
Tux's lil' helper
Tux's lil' helper
Posts: 102
Joined: Mon May 23, 2005 3:08 pm

  • Quote

Post by gordonp » Tue Nov 01, 2016 1:19 pm

Hi, @eccerr0r:

Yes, I saw/see exactly what you posted:

Code: Select all

# systemctl enable iptables
Created symlink from /etc/systemd/system/shutdown.target.wants/iptables-store.service to /usr/lib64/systemd/system/iptables-store.service.
Created symlink from /etc/systemd/system/basic.target.wants/iptables-restore.service to /usr/lib64/systemd/system/iptables-restore.service.

# systemctl enable ip6tables
Created symlink from /etc/systemd/system/shutdown.target.wants/ip6tables-store.service to /usr/lib64/systemd/system/ip6tables-store.service.
Created symlink from /etc/systemd/system/basic.target.wants/ip6tables-restore.service to /usr/lib64/systemd/system/ip6tables-restore.service.
But still no luck; at the console I still see failure:

Code: Select all

# systemctl restart iptables
Failed to restart iptables.service: Unit iptables.service failed to load: Invalid argument. See system logs and 'systemctl status iptables.service' for details.
and the logs still show:

Code: Select all

Nov 01 06:07:02 dragon systemd[1]: iptables.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
using the iptables-store and iptables-restore services does succeed, it seems (my iptables rules all look great):

Code: Select all

# systemctl start iptables-store.service

Nov 01 06:11:34 dragon systemd[1]: Starting Store iptables firewall rules...
-- Subject: Unit iptables-store.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit iptables-store.service has begun starting up.
Nov 01 06:11:34 dragon systemd[1]: Started Store iptables firewall rules.
-- Subject: Unit iptables-store.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit iptables-store.service has finished starting up.
-- 
-- The start-up result is done.

Code: Select all

# systemctl start iptables-restore.service

Nov 01 06:13:47 dragon systemd[1]: Starting Restore iptables firewall rules...
-- Subject: Unit iptables-restore.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit iptables-restore.service has begun starting up.
Nov 01 06:13:48 dragon systemd[1]: Started Restore iptables firewall rules.
-- Subject: Unit iptables-restore.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit iptables-restore.service has finished starting up.
-- 
-- The start-up result is done.
The thing is, while the -store and -restore seem to work fine, and my iptables-rules look great, it is scary that a reboot will leave me without any firewall until I manually do something :-O It is only the iptables.service and ip6tables.service which are unhappy and fail.

The fail-message says that there may be something missing (ExecStart= and ExecStop=). Googling also suggests there should be a [Service] section within the iptables.service file.

Overnight, I rebuilt *every single package* on one of my workstations (almost 1500 packages!!), but there was no change :-(

Curiouser and curiouser.
Top
eccerr0r
Watchman
Watchman
Posts: 10239
Joined: Thu Jul 01, 2004 6:51 pm
Location: almost Mile High in the USA
Contact:
Contact eccerr0r
Website

  • Quote

Post by eccerr0r » Tue Nov 01, 2016 3:35 pm

Strange, my computer seems to save iptables data upon reboot and restore them upon boot after enabling them.

I also get the same invalid argument errors when trying to "restart", "stop", or "start" the meta-service.

Does it actually work or does it just give errors when manually starting them?
Intel Core i7 2700K/Radeon Firepro W2100/24GB DDR3/800GB SSD
What am I supposed watching?
Top
gordonp
Tux's lil' helper
Tux's lil' helper
Posts: 102
Joined: Mon May 23, 2005 3:08 pm

  • Quote

Post by gordonp » Tue Nov 01, 2016 10:53 pm

eccerr0r wrote:Does it actually work or does it just give errors when manually starting them?
This was an interesting question! So, during a lull at work, I first verified that my iptables rules were present...

...then I rebooted.

And yes - upon restarting, my iptables rules were indeed present.

I'm not convinced that things are right, and I think I'll need to verify after any restart, that my iptables rules are there :-O
For troubleshooting and debugging, I'll want absolute certainty and control over my firewall!!!

It's beginning to sound like the iptables.service / ip6tables.service files require some alteration, such that "restart", "stop" and "start" work as expected. Do you also think this is the case, @eccerr0r? Or, are there some different tests you can suggest, so that a complete, thorough and helpful bug-report can be filed?

Thank-you!
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Tue Nov 01, 2016 11:43 pm

Without ExecStart the service isn't ment to be "started", but enabled. It seems that the iptables.service only makes dependencies... I't kind of a meta service file.
However there should be information for systemd that it's that kind of service. RemainAfterExit=yes would be one possible. There are other that I don't remember. Systemd has TONS of different config variables for different unit files. Yeah. It's complicated.

However if you still can enable it, it'll work as a meta service that pulls and pushes required units with it.

With a quick glance, this seems like a case for a bug report...
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
eccerr0r
Watchman
Watchman
Posts: 10239
Joined: Thu Jul 01, 2004 6:51 pm
Location: almost Mile High in the USA
Contact:
Contact eccerr0r
Website

  • Quote

Post by eccerr0r » Wed Nov 02, 2016 2:47 am

Yeah, it probably is a "bug" but as I don't have another non-Gentoo systemd machine to compare with, I'm not sure what it's supposed to look like.

The service, as it's written, agree with Zucca - it's a meta-service. The iptables-store and iptables-restore are the real "services" that save and restore your iptables settings. But from what I've been reading about other distributions, you're supposed to be able to start/stop this meta service, and not just enable/disable.

Don't know, maybe Gentoo is different... maybe not...
Intel Core i7 2700K/Radeon Firepro W2100/24GB DDR3/800GB SSD
What am I supposed watching?
Top
Thistled
Guru
Guru
User avatar
Posts: 572
Joined: Thu Jan 06, 2011 6:57 pm
Location: Scotland
Contact:
Contact Thistled
Website

  • Quote

Post by Thistled » Sat Nov 05, 2016 4:29 pm

Yep this seems to be a bug, and the developers look to have given up on it.

https://bugs.gentoo.org/show_bug.cgi?id=555920

No updates since August.

Does that mean we are supposed to run our systems without a firewall?

Crazy.
Whatever you do, do it properly!
Top
eccerr0r
Watchman
Watchman
Posts: 10239
Joined: Thu Jul 01, 2004 6:51 pm
Location: almost Mile High in the USA
Contact:
Contact eccerr0r
Website

  • Quote

Post by eccerr0r » Sat Nov 05, 2016 4:59 pm

The systemd iptables save/load services seems to work just fine, just it cannot start/stop the metaservice. It just looks like it doesn't work. The underlying services (-start and -restart) are what does the actual work and at least it does save them for me.

I don't know why this is different from other systemd distributions, supposedly just need to copy another distro's solution...
Intel Core i7 2700K/Radeon Firepro W2100/24GB DDR3/800GB SSD
What am I supposed watching?
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sat Nov 05, 2016 5:00 pm

Thistled wrote:Does that mean we are supposed to run our systems without a firewall?
Nope.
Try this:

Code: Select all

systemctl edit iptables.service
... and paste this code in:

Code: Select all

[Service]
Type=oneshot
ExecStart=/bin/false
... then

Code: Select all

systemctl daemon-reload
... and

Code: Select all

systemctl restart iptables
Yes. It's a workaround for now.
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
Thistled
Guru
Guru
User avatar
Posts: 572
Joined: Thu Jan 06, 2011 6:57 pm
Location: Scotland
Contact:
Contact Thistled
Website

  • Quote

Post by Thistled » Sat Nov 05, 2016 5:25 pm

Thanks for the reply Zucca, but.......
Matthias Maier gentoo-dev 2015-08-13 05:40:02 UTC
(In reply to Mike Gilbert from comment #9)
> Tweaked slightly:
>
> [Service]
> Type=oneshot
> ExecStart=/bin/false


This is worse. Please don't do that.
With ExecStart=/bin/false systemd tries to start the unit, it fails and after that the system state is "degraded":

# systemctl status
[...]
State: degraded
[...]

and the unit shows up in # systemctl

iptables.service loaded failed failed Store and restore iptables firewall rules

(In reply to Rick Harris from comment #0)
> [Service]
> ExecStart=/bin/true
> ExecStop=/bin/true

This is equally bad because it promotes iptables.service to look like a fully functional service (showing up a started, and listed in systemctl output)- but this is not the case.

The current behavior of iptables.service is to be just a short cut for

# systemctl enable iptables.service

The only "error message" it produces is a notification in the journal that it is not considered a functional service file. And as such it does not show up in systemctl output. Further, any action like

# systemctl start iptables

results in an error.

A target is also not an option because this would still require to enable both iptables-* services...
form the Bugzilla suggests that might not be a good idea.
Whatever you do, do it properly!
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sun Nov 06, 2016 12:21 am

You could try to leave ExecStart line out althogether. Oneshot type of service allows that.
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
Thistled
Guru
Guru
User avatar
Posts: 572
Joined: Thu Jan 06, 2011 6:57 pm
Location: Scotland
Contact:
Contact Thistled
Website

  • Quote

Post by Thistled » Sun Nov 06, 2016 12:58 am

Zucca wrote:You could try to leave ExecStart line out althogether. Oneshot type of service allows that.
I have tried this and the service fails to start.
Whatever you do, do it properly!
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sun Nov 06, 2016 7:04 am

Using three files for systemd to restore and flush the rules of iptables seems strange...

If I'd do it, I'd do it this way propably:

Code: Select all

[Service]
Type=oneshot
ExecStart=<command to restore rules>
ExecReload=<flush? + restore>
ExecStop=<command to flush>
RemainAfterExit=yes
I need to see later how I have done it on my Gentoo machine.
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
Logicien
Veteran
Veteran
User avatar
Posts: 1555
Joined: Fri Sep 16, 2005 8:04 am
Location: Montréal

  • Quote

Post by Logicien » Sun Nov 06, 2016 10:18 pm

If you look at the files of the iptables package, you can see

Code: Select all

equery f iptables
...
/usr/lib/systemd/system/ip6tables-restore.service
/usr/lib/systemd/system/ip6tables-store.service
/usr/lib/systemd/system/ip6tables.service
/usr/lib/systemd/system/iptables-restore.service
/usr/lib/systemd/system/iptables-store.service
/usr/lib/systemd/system/iptables.service
...
ipt6tables.service and iptables.service are dummy files. The real services are provided by ip6tables-restore.service, ip6tables-store.service, iptables-restore.service and iptables-store.service. So, depending on if you want to restore and/or store ip6tables and/or iptables rules, you choose the service(s) to enable.

ipt6tables.service and iptables.service do not need to be enabled to restore at boot and save at shutdown the Ip6tables and Iptables rules. It's like Samba, you do not enable samba.service who will fail, you enable smbd.service and/or nmbd.service and/or other related Samba services. This is Systemd who split related services in different units.
Paul
Top
Post Reply

15 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic