Scheduled maintenance — back soon.

~/blog/disable-libvirt-nwfilter-rules

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.

Comments

No comments yet

Be the first to leave a comment.

Leave a comment

Name and email required · moderated before publish · plain text only