[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-discuss] hostfwd not forwarding from host to guest

From: Lars Noodén
Subject: [Qemu-discuss] hostfwd not forwarding from host to guest
Date: Mon, 29 Jul 2019 14:09:57 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0


I have a qemu guest which boots fine and is accessible via the console.
Outbound networking from inside the guest works, I'm able to update the
guest system, add packages, and so on.

However, I am not able to connect from the host to the guest via the
forwarded ports.  The forwarded ports are unresponsive on the host.  For
example, when using this with qemu:

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

the following times out on the host:

        ssh -p 2222

What have I missed here?


PS.  On the host:

$ qemu-system-x86_64 --version
QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-8~deb10u1)
Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers

$ grep PRETTY /etc/os-release
PRETTY_NAME="Devuan GNU/Linux 3 (beowulf)"

$ qemu-system-x86_64 \
        -m 6G \
        -nographic \
        -enable-kvm \
        -name "foo" \
user,id=mynet0,net=,dhcpstart= \
        -net user,hostfwd=tcp::2222-:22 \

        -net user,hostfwd=tcp::8880-:80 \

        -net user,hostfwd=tcp::4443-:443 \

        -net nic,netdev=mynet0,model=e1000 \
        -drive format=raw,index=0,media=disk,file=foo.02.qemu.img \
        -boot c

On the guest, via the console:

$ grep PRETTY /etc/os-release
PRETTY_NAME="CentOS Linux 7 (Core)"

$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute
dynaic ens3
       valid_lft 86294sec preferred_lft 86294sec
    inet6 fec0::8bc:4054:f595:892f/64 scope site noprefixroute dynamic
       valid_lft 86296sec preferred_lft 14296sec
    inet6 fe80::fee8:40ce:7876:fccc/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

$ route -n
Kernel IP routing table
Destination   Gateway       Genmask        Flags Metric Ref Use Iface        UG    100    0     0 ens3  U     100    0     0 ens3

$ ping -q -n -c 1 -W 1 -I ens3
PING ( from ens3: 56(84) bytes of
--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.315/0.315/0.315/0.000 ms

$ wget -q http://www.google.com/ -O /dev/null; echo $?

$ sudo netstat -ntlp | awk '$4~/:22$/||NR<=2'
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address  Foreign Address  State  PID/Program
tcp       0   0*        LISTEN  1141/sshd
tcp6      0   0    :::22          :::*             LISTEN  1141/sshd

$ nc 22 | head -n 1

$ nc 22 | head -n 1

reply via email to

[Prev in Thread] Current Thread [Next in Thread]