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