从物理机里直接连上虚拟机有很多方面,比如网桥, iptables方式
最近看到一个有趣的方式,就是通过 QEMU monitor的设置来访问vm, libvirt后面也加入了对monitor scoket的控制,所以可以通过 virsh 命令来操作。
# virsh qemu-monitor-command --hmp instance-00000186 'help hostfwd_add'
hostfwd_add [vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport -- redirect TCP or UDP connections from host to guest (requires -net user)最后我们来看下结果:
# virsh qemu-monitor-command --hmp instance-0000018 'hostfwd_add ::2222-:22'
# ssh -p 2222 localhost
Password:
Last login: Tue Aug 22 10:28:38 2017 from 192.168.5.73
linux-wllabs:~ #
使用QEMU Monitor访问虚拟机
本文介绍了一种通过QEMU Monitor设置访问虚拟机的方法,这种方法允许用户通过virsh命令控制虚拟机,实现主机到虚拟机的端口转发,便于远程连接虚拟机。
2万+

被折叠的 条评论
为什么被折叠?



