15

I would like to forward more than one port.

This command run my VM and forwards RDP port successfully:

qemu-system-i386 -net nic,model=rtl8139 -net user,hostfwd=tcp::3389-:3389 -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet -k en-us -hda win.img -nographic

Tried other commands, but with no luck, all of them seems bad:

qemu-system-i386 -net nic,model=rtl8139 -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet -k en-us -hda win.img -nographic -redir tcp:443::443,tcp:992::992,tcp:1194::1194,tcp:5555::5555,udp:1194::1194,udp:500::500,udp:4500::4500,tcp:3389::3389

qemu-system-i386 -net nic,model=rtl8139 -net user,hostfwd=tcp::3389-:3389,tcp:443::443,tcp:992::992,tcp:1194::1194,tcp:5555::5555,udp:1194::1194,udp:500::500,udp:4500::4500 -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet -k en-us -hda win.img -nographic

The proper example would be very welcomed. Thank you.

Anna Parker
  • 331
  • 1
  • 2
  • 10

1 Answers1

17

Got it to work:

with -net:

qemu-system-i386 -net nic,model=rtl8139 \
  -net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::443-:443,hostfwd=tcp::992-:992 \
  -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet \
  -k en-us -hda win.img -nographic

Original answer: redir (legacy)

qemu-system-i386 -net nic,model=rtl8139 \
  -net user,hostfwd=tcp::3389-:3389 \
  -redir tcp:443::443 -redir tcp:992::992 \
  -redir tcp:5555::5555 -redir udp:1194::1194 -redir udp:500::500 \
  -redir udp:4500::4500 \
  -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet \
  -k en-us -hda win.img -nographic
schnatterer
  • 113
  • 5
Anna Parker
  • 331
  • 1
  • 2
  • 10
  • 9
    Note that -redir is a legacy option. To get the same thing working with hostfwd try: `-net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::443-:443,hostfwd=tcp::992-:992,etc...`. Also I can only get this working when forwarding to the main interface in the guest ( 10.0.2.15 ). – Joao Costa Dec 04 '15 at 15:30
  • @joao-costa you can get other interfaces forwarded by selecting the iface, like so ``` -netdev user,id=net0,hostfwd=tcp::5556-:22 ``` above from https://wiki.qemu.org/Documentation/Networking#How_to_get_SSH_access_to_a_guest – Marcin Sep 11 '20 at 08:58