티스토리 뷰

대학교 4학년 때 임베디드 수업을 이용해서 VMWare상에서 Bridged Networking 이 돼는 것을 보면서 굉장히 신기해 한적이 있다. 이걸 쓰는 이유는 상황에 따라서 다르겠지만... 뭐 어쨋든 리눅스 상에서 이것을 하는 방법이 필요했기에 자료 찾아보고 한번 설정해봄.


설정은 우분투를 이용했지만, 데비안에서도 그대로 적용 가능할 것이라고 생각함.
(https://help.ubuntu.com/community/VirtualBox 에서 자료 참고)

Networking

To start, NAT is by far the easiest way to get your guests connected to the interweb, but you may want to use the guests as servers. For this you need Host Networking.

Install Necessary Software

You will need to install bridge-utils and uml-utilities so that you can make a tap device and add it to a bridge.

sudo apt-get install bridge-utils uml-utilities

8.04 Hardy

To configure bridging, you basically go through three steps on the host machine. First you need to create a bridge. Next you create virtual interface(s). Then you add a real interface and virtual interface(s) to the bridge. Because of the scripts available on the distribution which take care of all the details, all of this sums up to two steps:

  • declare bridge and real network interface you add to it
  • declare virtual interfaces

Create a permanent bridge by editing /etc/network/interfaces

On the host machine:

$ sudo gedit /etc/network/interfaces
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0

# The loopback network interface
auto lo
iface lo inet loopback

"br0" is an arbitrary name. To take the modifications into account, restart the network:

$sudo /etc/init.d/networking restart

From now on, your system will always set up the bridge on boot. Note that this could slow down the boot time a little bit, because of the bridge coming up.

Declare virtual interfaces which will be used by VirtualBox by editing /etc/vbox/interfaces

On the host machine:

$ sudo gedit /etc/vbox/interfaces
# Each line should be of the format :
# <interface name> <user name> [<bridge>]
vbox0 <your user name> br0
vbox1 <your user name> br0
...

"vbox#" is an arbitrary name. You may declare here as many virtual interfaces as you wish, and add it to a bridge.

Later when you will configure the network of your virtual machine you will use the virtual adapter name "vbox#" for host networking. For example if you use the VirtualBox Qt graphical interface, enter "vbox#" in the "Interface Name" field, when choosing "Host interface".

To take the modifications into account, restart the VirtualBox host networking script:

$sudo /etc/init.d/virtualbox-ose restart

The virtual interfaces are now created and added to the bridge.

That's it! Now the different scripts will take care of cleanly create/configure/remove bridges and virtual interfaces when you boot and shut your system down.

Configure networking in VirtualBox

Once you have everything ready, you can start the VirtualBox management interface on the host machine, configure the network of your virtual machine, and by selecting "host networking", enter the name of one of the virtual adapter you have configured. Start your virtual machine, it gets a network card presented, that you can set up as you wish (static IP address, DHCP) using the network configuration tools inside the virtual machine.


대충 위와 같은 과정을 밟아가면 호스트 리눅스에서 게스트 리눅스로 직접 ip를 통해서 접근이 가능해진다.