• virtualbox 桥接 (转)


    virtualbox 自带的网络配置模式要么选择host-only,要么bridge,对于经常使用virtualbox的同学一定想要像vmware一样的nat配置,既可以让host访问guest,又可以让guest访问外部网络

    下面是安装步骤
    1. 建立桥接网络
    apt-get install bridge-utils

    修改/etc/network/interfaces
    增加以下内容:
    ####################################################
    # VirtualBox NAT bridge
    auto vnet0
    iface vnet0 inet static
    address 172.16.0.1
    netmask 255.255.255.0
    bridge_ports none
    bridge_maxwait 0
    bridge_fd 1
    up iptables -t nat -I POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
    down iptables -t nat -D POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
    ####################################################

    up网卡
    sudo ifup vnet0

    2. 启用ip 转发
    修改/etc/sysctl.conf 去掉这行的注释
    # Uncomment the next line to enable packet forwarding for IPv4
    net.ipv4.ip_forward=1

    运行下面命令使其生效
    sysctl -p

    3. 为虚拟机搭建dhcp服务器和dns服务器
    apt-get install dnsmasq
    修改/etc/dnsmasq.conf

    去掉下面的注释
    # Include a another lot of configuration options.
    #conf-file=/etc/dnsmasq.more.conf
    conf-dir=/etc/dnsmasq.d

    在/etc/dnsmasq.d/目录下面增加一个名为virtualbox的文件,内容为:
    #######################################
    interface=vnet0
    dhcp-range=172.16.0.2,172.16.0.254,1h
    dhcp-option=option:dns-server,172.16.0.1,208.67.222.222,208.67.220.220
    dhcp-option=option:domain-name,precision-m65
    # mac地址 , 主机名, 分配的ip
    dhcp-host=08:08:27:00:00:02,vmxp,172.16.0.20 # Windows XP
    dhcp-host=08:08:27:00:00:03,vmubuntu,172.16.0.30 # Ubuntu
    #######################################

    4.修改virtualbox 虚拟机配置
    a. 打开虚拟机配置
    b. 选择网络
    c. 选择Attached to: “Bridged Adapter”
    Name: “vnet0″
    Advanced-> Mac Address:080827000002 #对应3步中virtualbox给虚拟机分配的mac地址,注意去掉冒号

    d. 应用生效

    启动虚拟机,看看是不是分配了正确的地址,上面配置在ubuntu 10.04 LTS上测试通过,其他发行版类似

  • 相关阅读:
    数组优化 Dijkstra 最短路
    F
    树 (p155, 从中序和后续回复二叉树)
    矩阵连乘 LRJ白书 p141 栈 解析表达式
    Train Problem II HDU 1023 卡特兰数
    codevs 1166 矩阵取数游戏
    BZOJ 2754: [SCOI2012]喵星球上的点名
    2017.6.11 校内模拟赛
    HDU 2896 病毒侵袭
    UvaLive 4670 Dominating Patterns
  • 原文地址:https://www.cnblogs.com/liubaocheng999/p/3267136.html
Copyright © 2020-2023  润新知