1

I have a setup like below: qemu as hypervisor. ubuntu running as a virtual machine with two network adapters:

  • eth0: connected to a user network.
  • ssh port is forwarded to a port from host OS.
  • eth1: connected to a tap network that is on default NAT bridge of libvirt.

what I want to do is to be able to ssh from outside of the host to the vm using forwarded port:

  • ssh username@host_ip -p forwarded_port

however, ssh command is getting timeout.

I am able to ssh from the host to the vm using forwarded port:

  • ssh username@localhost -p forwarded_port

interestingly enought, when I remove the second interface that is connected to NAT network, I am able to ssh to the server from outside. so I know for sure that firewall is not blocking anything.

what am I doing wrong? is it something related to ssh or the network?

EDIT: I figured when I set the nat interface down, ssh from outside is working.

6
  • Why are you using second interface ? If you use eth0, then you will be able to connect to it from outside without that eth1 Aug 16, 2019 at 19:11
  • What command did you use to forward the port? Is that forward listening on all interfaces? Is the destination unambiguous?
    – Andy
    Aug 16, 2019 at 23:22
  • 1
    @Andy I use port forwarding for qemu as a netdev argument. I can even see the packet on the VM using tcpdump. I think ssh server tries to respond to it through the default gateway which is in the other network.
    – Amir H
    Aug 16, 2019 at 23:30
  • Sounds like you found your problem. You need to mess with ip route priorities on your guest to make eth0's gateway the preferred default gateway.
    – Andy
    Aug 16, 2019 at 23:32
  • @Andy this is what I don't want to do. I want to be able to send only ssh traffic through the user type network (eth0 in the example), which is not my default gateway network. is this possible?
    – Amir H
    Aug 16, 2019 at 23:36

0

You must log in to answer this question.

Browse other questions tagged .