Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KVM, NAT, ssh into VM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Tanktalus
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2005
Posts: 86

PostPosted: Fri Nov 16, 2012 9:06 pm    Post subject: KVM, NAT, ssh into VM Reply with quote

I've got this setup with VirtualBox, but I'd like to try getting it to work with KVM instead, partly just to get rid of Oracle :-) and partly just to learn more about KVM.

I run a VirtualBox VM which has another distro of Linux in it. Once it starts up, I can ssh into it (-p 2222, though it's on port 22 in the VM, and should only work from localhost) and run X apps through that ssh tunnel. The applications running in the VM have access to my real machine's VPN since it's using NAT.

So I've managed to get QEMU/KVM running the same VirtualBox disk image. If I ssh from that image to a machine behind the VPN, it seems to work using vde/slirpvde (but ping doesn't work?). However, I haven't yet figured out how to allow my real machine to ssh into the VM.

I'd also like to be able to expose my DNS server on my main machine to the VM, but without exposing it to any other machines on the network (since no other machine has access to the VPN, and that DNS server handles redirections to the internal network behind the VPN). If I can't get that to work, I'll just have the VM only use the VPN DNS (this works now), so it's not critical.

Any advice would be appreciated.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21591

PostPosted: Fri Nov 16, 2012 10:02 pm    Post subject: Reply with quote

Please post the command line you use to start the VM.
Back to top
View user's profile Send private message
Tanktalus
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2005
Posts: 86

PostPosted: Sat Nov 17, 2012 2:00 am    Post subject: Reply with quote

Not much to it. I think this means it gets to use 2 CPUs (I have 4) and 1GB RAM (also not an issue, I have 12GB).

Code:
qemu-kvm -net vde -net nic,macaddr=00:00:00:00:00:01 -smp 2 -m 1024 *.vdi
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3922
Location: Hamburg

PostPosted: Sat Nov 17, 2012 9:23 am    Post subject: Reply with quote

I'm using a TAP device :
Code:
qemu-kvm --name foo -m 2047 -hda ~/virtual/kvm/foo.img -cdrom ~/Downloads/tails-i386.iso -boot d -smp 2 -net nic,vlan=0,model=virtio -net tap,vlan=0,ifname=tap3,script=no,downscript=no -vga qxl -spice port=5930,disable-ticketing
to start a KVM image on my host, then I'm able to ssh from the guest to my host.
The TAP device I created via gentoo's way :
Code:
# /etc/conf.d/net
#

#       KVM
#
bridge_br0="tap0 tap1 tap2 tap3"
config_br0="192.168.0.254/16"
brctl_br0="setfd 0
sethello 10
stp off"
rc_net_br0_need="net.tap0 net.tap1 net.tap2 net.tap3"

config_tap0="null"
tuntap_tap0="tap"
tunctl_tap0="-u tfoerste"

...

#       LAN
#
config_eth0="null"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum