Score:0

How do I route ALL VM (qemu-kvm, libvirt) traffic through proxy running in Host?

ro flag

Host: Ubuntu 20.04
Proxy Client and Server: V2ray
Proxy Client connecting to Server and is available in the host on 127.0.0.110808 for Socks and 127.0.0.1:10809 for http.
VMs: Multiple vms running in the Host via qemu-kvm and libvirt

My Goal: route ALL VMs traffic through the proxy running in host.

I used to be able to use OpenConnect in the host and as that would effect all the machines traffic (I think), it took care of the business. But now I am forced to use V2Ray and can't figure out how to route all the VM traffic through the proxy client in host machine. When I say route all traffic, I mean that I have managed to used 3rd party software like v2raya which has options like system-proxy and ip forwarding. Which would effect the browser in VM but when using dig command to check vms public ip such as: dig +short myip.opendns.com @resolver1.opendns.com it would not be effected. I need to not configure the VM AT ALL!
I have tried iptables but I'm very new to networking and don't think have got it right.

Here is what I have tried:

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
sysctl -w net.ipv4.conf.all.send_redirects=0

iptables -t nat -A PREROUTING -i virbr0 -p tcp --dport 80 -j REDIRECT --to-port 10809
iptables -t nat -A PREROUTING -i virbr0 -p tcp --dport 443 -j REDIRECT --to-port 10809
ip6tables -t nat -A PREROUTING -i virbr0 -p tcp --dport 80 -j REDIRECT --to-port 10809
ip6tables -t nat -A PREROUTING -i virbr0 -p tcp --dport 443 -j REDIRECT --to-port 10809

virbr0 is the network interface automatically created by libvirt upon installation and does the networking stuff for vms (assign ips, etc.) What should I do? I'm also very open to using whatever suggestion that might work Thanks

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.