qemu guest is bypassing host's firewall

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I've got a Ubuntu host running several virtual machines using qemu-kvm.



Every guest should use our local DNS server, so I blocked outgoing DNS requests using ufw on the host machine:



sudo ufw deny out dns


It's working on the host fine and something like this won't work:



dig stackexchange.com @8.8.4.4


However from guests, everyone can use any DNS servers they like. Actually I can see the packets going through the host to 8.8.4.4 without being blocked by host and the response being received by the guests.



The guests are using NAT as their network configuration, and I'm wondering is this how NAT works or I'm missing something else here?










share|improve this question

















  • 2




    ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
    – Michael Hampton
    Aug 28 at 19:16







  • 1




    Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
    – dirkt
    Aug 29 at 5:42














up vote
1
down vote

favorite












I've got a Ubuntu host running several virtual machines using qemu-kvm.



Every guest should use our local DNS server, so I blocked outgoing DNS requests using ufw on the host machine:



sudo ufw deny out dns


It's working on the host fine and something like this won't work:



dig stackexchange.com @8.8.4.4


However from guests, everyone can use any DNS servers they like. Actually I can see the packets going through the host to 8.8.4.4 without being blocked by host and the response being received by the guests.



The guests are using NAT as their network configuration, and I'm wondering is this how NAT works or I'm missing something else here?










share|improve this question

















  • 2




    ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
    – Michael Hampton
    Aug 28 at 19:16







  • 1




    Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
    – dirkt
    Aug 29 at 5:42












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I've got a Ubuntu host running several virtual machines using qemu-kvm.



Every guest should use our local DNS server, so I blocked outgoing DNS requests using ufw on the host machine:



sudo ufw deny out dns


It's working on the host fine and something like this won't work:



dig stackexchange.com @8.8.4.4


However from guests, everyone can use any DNS servers they like. Actually I can see the packets going through the host to 8.8.4.4 without being blocked by host and the response being received by the guests.



The guests are using NAT as their network configuration, and I'm wondering is this how NAT works or I'm missing something else here?










share|improve this question













I've got a Ubuntu host running several virtual machines using qemu-kvm.



Every guest should use our local DNS server, so I blocked outgoing DNS requests using ufw on the host machine:



sudo ufw deny out dns


It's working on the host fine and something like this won't work:



dig stackexchange.com @8.8.4.4


However from guests, everyone can use any DNS servers they like. Actually I can see the packets going through the host to 8.8.4.4 without being blocked by host and the response being received by the guests.



The guests are using NAT as their network configuration, and I'm wondering is this how NAT works or I'm missing something else here?







dns virtual-machine firewall qemu nat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 28 at 17:16









Ravexina

962719




962719







  • 2




    ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
    – Michael Hampton
    Aug 28 at 19:16







  • 1




    Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
    – dirkt
    Aug 29 at 5:42












  • 2




    ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
    – Michael Hampton
    Aug 28 at 19:16







  • 1




    Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
    – dirkt
    Aug 29 at 5:42







2




2




ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
– Michael Hampton
Aug 28 at 19:16





ufw deny applies only to locally originating or terminating traffic, not forwarded traffic such as to your VMs. You probably need a different firewall manager, other than ufw. You also should be using virt-manager instead of manually creating VMs. Libvirt has its own network filter which can block such traffic.
– Michael Hampton
Aug 28 at 19:16





1




1




Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
– dirkt
Aug 29 at 5:42




Depending on how you configured networking with with qemu-kvm, packets may or may not get forwarded by the host, and if they are not forwarded, they won't go through the iptables FORWARD chain and can't be filtered. So make sure you get a tun/tap interface in the host for each VM, setup the host to forward packets (and masquerade if necessary), and then you can add the correct filtering rules (with iptables if ufw can't do that).
– dirkt
Aug 29 at 5:42















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465350%2fqemu-guest-is-bypassing-hosts-firewall%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465350%2fqemu-guest-is-bypassing-hosts-firewall%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)