VMの設定: Network
NAT
Host-only Adapter
- vboxnet0がない場合、VertualBoxのFinderのメニューの設定のネットワークで追加しておく
Networkの設定
Debianのコンソールにログインしてネットワークの設定をする
host
jfk@debian:~$ sudo vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
auto eth1
iface eth1 inet static
address 192.168.56.101
jfk@debian:~$ sudo /etc/init.d/networking restart
NatのGatewayを乗っ取るので、eth1にはgatewayを追加しない
routeコマンドで設定を確認する
host
jfk@debian:~$ sudo route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth1
192.168.56.0 * 255.255.255.0 U 0 0 0 eth1
Nat+Host-only networkの設定の完了
ローカルマシーンからssh
で接続ができるようになり、サーバーからNat経由で外部へ接続できるようになる
local
$ ssh 192.168.56.101 -l jfk
さて、何やろう。