New ‘redir’ / ‘hostfwd’ syntax for Qemu

it’s mandatory now in 2.9 so where we go.

Instead of:

-redir tcp::42323:23

which listens on all ip’s and redirects host port 42323 to port 23 on the default guest IP address of 10.0.2.15 we now have to use

-net user,hostfwd=tcp::42323-:23

as you could tell from this ‘easy’ syntax.

-netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport

Right?

2 thoughts on “New ‘redir’ / ‘hostfwd’ syntax for Qemu

  1. Hi, sorry to bother you. I have a problem with Qemu 0.15.1 and Windows 98 OEM. Basicly I’ve installed the nerwork card and I’m trying to use the the user mode networking feature of QEMU. However the DHCP server gives a weird IP address to my machine and does not provide a gateway. I’ve tried to configure the network statically providing the default ip addresses.

    10.0.2.15 ip address
    10.0.2.2 gateway
    10.0.2.3 DNS

    But I can’t still connect to the internet.
    I’ve tried to use Windows XP as guest but it gives me 0.0.0.0 as IP Address.

    To compile it I’ve edited the configure file to add adlib to the sound card list to build, I’ve also edited it so it does not try to link with libiberty as it should not be required (?). I’ve also edited the CFLAGS in config-host.mak replacing “-g -O2” with “-g -O1” to avoid crash when QEMU tries to access hard disk images.

    I also have tried to use Qemu 1.1.1-1 compiled using your instructions and it works fine, however it is slower in comparison to Qemu 0.15.1 I would like to stick with the earlier version because it allows me to play Age of Empires 2 at an acceptable speed.

    If you want to help me send a mail

  2. better example is something like this:

    -netdev user,id=ethernet.0,hostfwd=tcp::5555-:1522,hostfwd=tcp::9999-:9,hostfwd=tcp::17010-:17010,hostfwd=tcp::17013-:17013
    -device rtl8139,netdev=ethernet.0

    Or imagine, say you are on a VPS and wanting to ‘hide’ your server to the loopback:

    ./qemu -L pc-bios -m 224 -vnc :0 -hda OS.vmdk -hdb data.vmdk -vnc 127.0.0.1:0 -netdev user,id=ethernet.0,hostfwd=tcp:127.0.0.1:1433-:1433,hostfwd=tcp:127.0.0.1:3389-:3389 -device pcnet,netdev=ethernet.0

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.