How use proxy for QEMU?
05:10 18 Aug 2022

I have QEMU for emulating, and I have to start it from terminal (I'm using qemu-system-x86_64), but on host machine to have access the network I got to use proxy :. I want QEMU to redirect all network requests to :, where I have a proxy, is there a way to do it from host? May be using -netdev or another option?

UPD:

Let's say I want to do # apt update on the guest QEMU, so I need to be connected to the network, but the only way this can be done is via host proxy.

If I'm not mistaken, QEMU, by default, will redirect the request to 10.0.2.2 gateway, then it will forward the request somewhere (tbh, I don't know where) and tries to reach the network.

So, I have a port on my host machine, let's say 12345. apt config on the host looks like:

Acquire::http::proxy "http://:12345/";

I want the similar for the guest QEMU, let's say:

Acquire::http::proxy "http://:"

Here is some port on guest QEMU machine and is guest's IP address. When apt tries to reach smth, its request should be redirected to the :, which should be redirected to the host's 12345 port, where the actual proxy is set.

This is just an example how it can be done (in theory, maybe), but as a way QEMU may redirect all network request to host specific port (12345) without any proxy on the guest, but I don't know how to do it :)

This is related not only for apt. apt here is only an example.

So, I want QEMU to redirect network request from guest to host on a specific port. Is there a way to do so?

I think hostfwd now is not the thing I want, because it will redirect to the guest some requests, but I already have smth that listening on 12345 port.

network-programming proxy qemu