My *nix world

Disable libvirt nwfilter rules

By default the libvirt daemon will create some iptables rules for its NAT virtual network (if any). Those rules may not be exactly what you want, so the question is "how to disable libvirt nwfilter rules?".

One possible solution (by the book) is to create a bridged virtual network instead of the NAT one.

If that is too complicated for you then you can hack the init script of libvirtd daemon (/etc/init.d/libvirtd) like I did.

All you have to do is to change the start() function from this one:

start() {
    ebegin "Starting libvirtd"
    start-stop-daemon --start --env KRB5_KTNAME=/etc/libvirt/krb5.tab 
    --exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS}
    eend $?
}

to the following one:

start() {
    ebegin "Starting libvirtd"
    start-stop-daemon --start --env KRB5_KTNAME=/etc/libvirt/krb5.tab 
    --exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS}
      ebegin "  My hack: flushing libvirt iptables rules..."
        sleep 1
        /sbin/iptables -F <your_chain or your_rules>
      eend $?
    eend $?
}

By flushing the iptables chain/rules you just disabled libvirt nwfilter rules. Simple, right? Maybe it's not the most orthodox way of doing it but it always works.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
Disable libvirt nwfilter rules

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Disable libvirt nwfilter rules

Latest posts by Eugen Mihailescu (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *