kvmネットワークの設定方法(redir)

1)先にやったような10.0.2.xなるクローズドな環境の場合、


 ただし、192.168.1.x(host OSの属する物理LAN網)にはhostOS(ルータとして動く)越しでアクセス可能。
 
HostOSの属する物理LAN網から10.0.2.xにはアクセス不可(10.0.2.2もNGと思う)

hirasawa@deb505-64-38:~$ kvm -hda cent55-i386.img -boot c -m 2GB -monitor stdio

2) redir オプション (redir tcp:2222::22) ... hostの2222ポートとguestの22ポートをバインドして、 host:2222 から guest:22へリダイレクト

これにて、特定のポート(ここではguest:22ポート)へのアクセスができるようになる

LAN内の外部PCからホストPCにnmapをかけると

hirasawa@ubuntu910-11:~$ nmap 192.168.1.38

Starting Nmap 5.00 ( http://nmap.org ) at 2011-02-07 11:53 JST
Interesting ports on deb505-64-38.hirasawa.local (192.168.1.38):
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
2222/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.17 seconds
hirasawa@ubuntu910-11:~$ 

LAN内の外部PCからport2222にsshをかけてみるですよ

hirasawa@ubuntu910-11:~$ ssh -p 2222 192.168.1.38
The authenticity of host '[192.168.1.38]:2222 ([192.168.1.38]:2222)' can't be established.
RSA key fingerprint is 9b:2e:2d:71:6c:56:f0:c4:f5:c6:75:e1:4e:5e:c4:a4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.1.38]:2222' (RSA) to the list of known hosts.
hirasawa@192.168.1.38's password: 
[hirasawa@localhost ~]$ 

ぱちぱち