Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
systemd, libvirtd.service and iptables
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Spinmc
n00b
n00b


Joined: 06 Sep 2010
Posts: 39
Location: Ruvo di Puglia (BA) Italy

PostPosted: Tue Apr 22, 2014 6:36 pm    Post subject: systemd, libvirtd.service and iptables Reply with quote

Hello, I need some help to correctly configure a service file of libvirtd for my needs.
Some backgrounds.
I noticed that on stopping the libvirtd service it doesn't deactivate nat-ed networks, so there remain all the iptables rules libvirt creates to act as a dhcp server. This is very bad if you enable iptables-{save,restore}.service units because it will save those rules across reboots, then when libvirtd service starts on the next boot it will add again its rules, and again and again...
So I think it should be a better approach to let libvirt deactivate its networks before executing iptables-save on system shutdown. For this purpose i tried to add the following in libvirtd.service:
Code:
ExecStop=/bin/bash -c "for net_list in $(/usr/bin/virsh net-list | /bin/grep -i active | awk '{ print $1 }'); do /usr/bin/virsh net-destroy $net_list; done"

In this way it works very well when I run systemctl stop libvirtd BUT it doesn't work on system shutdown/reboot. Systemd simply ignores the ExecStop directive on system shutdown. Why?
Have you never faced it before?
Thanks.
_________________
Excuse me for my English, I'm working on it! :-)

Proud Gentoo donor. Help Gentoo making a donation so do you.

My italian-language blog: http://www.paba-blog.it ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum