Edit: Since macvtap
is not working for communication between host and guest, I tried to used a bridge
, but then there's no internet on the host and ping
or ssh
still doesn't work.
This is how I've created a bridge
:
nmcli connection add type bridge ifname br0
Output:
Connection 'bridge-br0' (bf1406b0-4ea8-4338-9edc-0f58fd019bec) successfully added.
nmcli con add type ethernet con-name br-slave-1 ifname enp0s25 master br0
nmcli con add type ethernet con-name br-slave-1 ifname enp0s25 master br0
nmcli con modify bridge-br0 bridge.stp no
nmcli connection add type ethernet ifname bridge-br0 ipv4.method auto
Output:
Connection 'ethernet-bridge-br0' (6c2c5495-6e43-4cd5-a574-014042987781) successfully added.
After reboot:
nmcli con show
NAME UUID TYPE DEVICE
bridge-br0 bf1406b0-4ea8-4338-9edc-0f58fd019bec bridge br0
br-slave-1 a998c09f-5f46-4586-b654-cdfa6a21dca5 ethernet enp0s25
ethernet-bridge-br0 6c2c5495-6e43-4cd5-a574-014042987781 ethernet --
Wired connection 1 8559f62b-0cb9-3935-ba65-b6d57c0043c8 ethernet --
Now if I disconnect br-slave-1
:
nmcli con down br-slave-1
I get the internet back on the host but then there's no internet on guest and ping still wouldn't work:
So is there a way to use ssh
between host and guest while using qemu with kvm, using nmcli
or NetworkManager GUI
? Many thanks.
Note: As I need to use few different wireless networks on and off, I like to stay away from netplan
or network interfaces
, hence I'm trying to setup bridge either using nmcli
or NetworkManager GUI
.
Original post:
I'm trying to SSH into a guest from the host. Both host and guest machines are Ubuntu MATE 21.04.
Internet works just fine both from host and guest machines.
IP addresses:
(1) Router: Asus RT AC68U > 192.168.1.1
(2) Host: Ubuntu MATE 21.04 > 192.168.1.106
(3) Guest: Ubuntu MATE 21.04 > 192.168.1.139
Firewall have been disabled/stopped on all three:
(1) Router: Asus RT AC68U > SPI Firewall > Disabled
(2) Host: Ubuntu MATE 21.04 > sudo systemctl stop nftables
(3) Guest: Ubuntu MATE 21.04 > sudo systemctl stop nftables
When I try to ssh-copy-id
, I get this error: No route to host
ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: connect to host 192.168.1.139 port 22: No route to host
So I tried to ping
(does not work either way; "host to guest" or "guest to host"):
ping 192.168.1.139
PING 192.168.1.139 (192.168.1.139) 56(84) bytes of data.
From 192.168.1.106 icmp_seq=1 Destination Host Unreachable
From 192.168.1.106 icmp_seq=2 Destination Host Unreachable
However ping
does work from either "host to router" or "guest to router":
ping
from host to router:
ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.400 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.339 ms
ping
from guest to router:
ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.651 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.625 ms
Host and guest machines are connected through a network bridge br0
, which I've created using Netwrok Manager GUI. Bridge br0
have two "bridged connections", br0 slave 1
and br0 slave 2
.
Enable STP (spanning Tree Protocol
is "unchecked". Though it did not make any difference even I "checked" it.
Additional details which I think would be helpful:
sudo nano /etc/libvirt/qemu/networks/host-bridge.xml
<network>
<name>host-bridge</name>
<uuid>0ae7be62-9f9e-4346-9309-88985dd0f5ad</uuid>
<forward mode='bridge'/>
<bridge name='br0'/>
</network>
virsh net-list --all
Name State Autostart Persistent
---------------------------------------------
host-bridge active yes yes
Results of ip a
and ip r
on the host machine:
ip a
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 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether e0:69:95:4d:7c:9c brd ff:ff:ff:ff:ff:ff
inet 192.168.1.106/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s25
valid_lft 599784sec preferred_lft 599784sec
inet 192.168.1.104/24 brd 192.168.1.255 scope global secondary noprefixroute enp0s25
valid_lft forever preferred_lft forever
3: wlxd0374547816a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether d0:37:45:47:81:6a brd ff:ff:ff:ff:ff:ff
4: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 96:d5:ab:3c:a7:e8 brd ff:ff:ff:ff:ff:ff
7: macvtap2@enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 500
link/ether 52:54:00:1f:6a:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.1.140/24 brd 192.168.1.255 scope global noprefixroute macvtap2
valid_lft forever preferred_lft forever
ip r
default via 192.168.1.1 dev enp0s25 proto dhcp src 192.168.1.104 metric 202
default via 192.168.1.1 dev macvtap2 proto dhcp src 192.168.1.140 metric 207
169.254.0.0/16 dev macvtap2 scope link metric 1000
192.168.1.0/24 dev enp0s25 proto dhcp scope link src 192.168.1.104 metric 202
192.168.1.0/24 dev macvtap2 proto dhcp scope link src 192.168.1.140 metric 207
Results of ip a
and ip r
on the guest machine:
ip a
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 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:1f:6a:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.1.139/24 brd 192.168.1.255 scope global dynamic noprefixroute enp2s0
valid_lft 603989sec preferred_lft 603989sec
inet6 fe80::d316:3db7:9af5:8d0c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
ip r
default via 192.168.1.1 dev enp2s0 proto dhcp metric 100
169.254.0.0/16 dev enp2s0 scope link metric 1000
192.168.1.0/24 dev enp2s0 proto kernel scope link src 192.168.1.139 metric 100
NIC details (from Virtual machine manager) of the guest machine:
Virtual Network Interface:
Network source: Macvtap device
Device name: enp0s25
Device model: virtio
XML:
<interface type="direct">
<mac address="52:54:00:1f:6a:cd"/>
<source dev="enp0s25" mode="bridge"/>
<target dev="macvtap2"/>
<model type="virtio"/>
<alias name="net0"/>
<address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
</interface>
OS: Ubuntu MATE 21.04
qemu: 1:5.2+dfsg-9ubuntu3
bridge-utils: 1.6-5ubuntu1
virt-manager: 1:3.2.0-3
libvirt-daemon: 7.0.0-2ubuntu2
Thanks alot in advance.
Edit-1:
brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.96d5ab3ca7e8 no