VirtualBox 4.2.4 Network setting

前言:

VirtualBox版本眾多網路上的教學,大部分都是舊版的。自己試了很久終於弄出點東西來。筆記下來怕到時候忘了。

請先看[轉]快速理解VirtualBox的四种网络连接方式

環境:

VirtualBox version:4.2.4

Host:windows 7 (固定ip)

Guest:windows xp , fedora

方法:

這邊實作兩個方法

1.Bridged Adapter

2.NAT(用Linux當router,非VirtualBox的NAT)

設定:

每當一個guest os 裝完之後,他本身就自動有NAT上網的功能,ip為10開頭。

這ip不能讓 Host 或者 other Guest ping到。

但因為個人需要 Host , Guests 之間都能夠連線到對方,所以在每個windows 7下 IPv4 [進階TCP/IP設定]中多設定一個IP (192.168.56.3)

mask:255.255.255.0

在Guest os 中各增加一個一張介面卡(原本只有NAT那張網卡)

選擇[橋接介面卡]並選擇自己主機端的那張網卡。接著分別到windows xp , fedora中

 

*注意:橋接介面卡 若是在 介面卡1上面設定的,則其他Guest OS的橋接介面卡也必須設在 介面卡1上

分別給定一組靜態ip,注意每種作業系統設定靜態ip的方法未必相同請自行查詢。

xp:192.168.56.9

fedora:192.168.56.12

使用ping指令可以觀察到都可以互相ping到了。

因為實驗需要,所以需要用fedora當router來分析xp上的封包。

fedora Linux   eth0  --> Internet (by 預設的NAT)
               eth1  --> Lan (192.168.56.12)

一、首先需要對fedora做以下設定

Configuration steps

1) First enable packet forwarding
2) Next setup Network Address Translation using IPTABLES MASQUERADE targets
3) Save the changes

  1)

#enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
2)
# Set up IP FORWARDing and Masquerading (NAT)
       iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
       iptables --append FORWARD --in-interface eth1 -j ACCEPT

3)

在  /etc/rc.local 內 添加以上指令,重開機後就會自動掛載了
二、在對xp做設定(對橋接的那張網卡上做設定)

8.8.8.8 is DNS server of Google



[註1]enable IP forwarding

1) Open linux kernel configuration file (you must be a root user or use su - command to become a root user):
# vi /etc/sysctl.conf

2) Add/modify following line:
net.ipv4.ip_forward = 1

Step # 2 Restart network
# /etc/init.d/network restart

或者 

# service network restart

 

ref:

http://users.telenet.be/mydotcom/howto/lanconnect/router/linux.htm

Google 超快速DNS伺服器:8.8.8.8與8.8.4.4

http://briian.com/?p=6667

http://www.liusuping.com/ubuntu-linux/iptables-firewall-setting.html


posted @ 2012-12-22 13:24  jeremyatchina  阅读(1226)  评论(2编辑  收藏  举报