dannygao 写了:代码: 全选
sudo gedit /etc/udev/rules.d/10-local.rules
添加一行
KERNEL=="tun", NAME="net/%k", GROUP="vboxusers", MODE="0660"
并存盘
输入以下代码
代码: 全选
sodu sysctl net.ipv4.ip_forward=1
sodu VBoxTunctl -b -u danny
sodu ip link set tap0 up
sodu ip addr add 192.168.1.101/255.255.255.0 dev tap0
sodu parprouted wlan0 tap0
sodu route add -net 192.168.1.0 netmask 255.255.255.0 tap0
sodu iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
这里 danny 是你自己的用户名,192.168.1.101 和 192.168.1.0 改成你自己的网断
wlan0 是无线网卡的名字
在 VirtualBox 中,设置
连接方式: Host Interface
Host Interface: tap0
如果不行,换一下适配器类型。我的是:PCNET-PCI II
启动虚拟机,然后设置 IP,DNS 和 MASK
你好,
我按照你的帖子设置之后,在guest中可以ping通网关,但是不能上网,
此外不能ping通host的ip
我的设置如下:
sysctl net.ipv4.ip_forward=1
VBoxTunctl -b -u bzimage
ip link set tap0 up
ip addr add 192.168.9.200/255.255.255.0 dev tap0
parprouted wlan0 tap0
route add -net 192.168.9.0 netmask 255.255.255.0 tap0
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
其中192.168.9.200是本网段未用的ip
然后在geust中设置ip为:
ip:192.168.9.61
mask:255.255.255.0
gw:192.168.9.1
dns:192.168.9.1
在host中使用ifconfig看到的信息如下,其中tap0的Bcast好像不太正确,请帮我看看,谢谢:
eth0 Link encap:Ethernet HWaddr 00:1d:72:96:63:fd
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Memory:fe000000-fe020000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:256 errors:0 dropped:0 overruns:0 frame:0
TX packets:256 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16196 (16.1 KB) TX bytes:16196 (16.1 KB)
tap0 Link encap:Ethernet HWaddr 3a:17:aa:55:36:64
inet addr:192.168.9.200 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::3817:aaff:fe55:3664/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:364 errors:0 dropped:0 overruns:0 frame:0
TX packets:54 errors:0 dropped:9 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:36771 (36.7 KB) TX bytes:2588 (2.5 KB)
wlan0 Link encap:Ethernet HWaddr 00:1e:3e:93:66:c9
inet addr:192.168.9.66 Bcast:192.168.9.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1
RX packets:4565 errors:0 dropped:0 overruns:0 frame:0
TX packets:3819 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2387789 (2.3 MB) TX bytes:353072 (353.0 KB)
wmaster0 Link encap:UNSPEC HWaddr 00-1F-3C-93-66-C9-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)