0

I am running an Ubunut on qemu.

Here is the command I execute to lunch the machine

qemu-system-x86_64 \
  -cdrom ubuntu-18.04.1.0-live-server-amd64.iso \
  -drive file=ubuntu-18.04-server-amd64.img.qcow2,format=qcow2 \
  -m 4G \
  -smp 2 \
  -net nic,addr=0x10
  -vga virtio \
;

I am trying to expose an IP from the qemu machine which is is accessible my host machine, but qemu is only showing me a local IP which is 127.0.0.2, how can I change this?

1

One way to go would be to declare "user mode" host networking, and use forwarding of certain host ports to guest ports. For instance, the qemu command line might have the following additional declaration:

-net user,hostfwd=tcp::10022-:22

That declaration links up the guest for "user mode" networking, where it basically shares the host's interface for Internet access, and in addition (by the hostfwd=... part), provides forwarding for incoming or local tcp connections on host port 10022 to be forwarded to guest port 22.

The user mode networking is a simple choice for many use cases.

See also man qemu-system-x86 for additional host side methods (such as tap and bridge), as well as online documentation, e.g., Qemu Network Options

  • Thanks, from the host machine, I am trying to access a file that is hosted on the nginx of qemu machine. on the qemu machine I can access a file via localhost/myfile so it's basically on port 80 of the qemu machine. – Benjamin Dec 19 '18 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.