Bridging eth0 and vboxnet0 and using ISC DHCP server to provide dynamic IPs

8,647

This is fixed. For anyone interested please see the details below.

  1. Install bridge-utils.

  2. sudo leafpad /etc/network/interfaces

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
    dns-nameservers 10.228.129.113 10.228.129.114
    
  3. sudo leafpad /etc/rc.d/rc.local

    vboxmanage hostonlyif ipconfig vboxnet0 --ip 192.168.0.3 --netmask 255.255.255.0
    
    brctl addbr br0
    
    ifconfig eth0 0.0.0.0 down
    ifconfig vboxnet0 0.0.0.0 down
    
    brctl addif br0 eth0
    brctl addif br0 vboxnet0
    
    ifconfig eth0 up
    ifconfig vboxnet0 up
    ifconfig br0 192.168.0.1 netmask 255.255.255.0 up
    
    /sbin/iptables -P FORWARD ACCEPT
    /sbin/iptables --append FORWARD --in-interface br0 -j ACCEPT
    /sbin/iptables --table nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
    
    restart isc-dhcp-server
    
    exit 0
    
  4. sudo leafpad /etc/default/isc-dhcp-server

    INTERFACES="br0 eth0"
    
  5. Restart your computer

Share:
8,647

Related videos on Youtube

AVarghese
Author by

AVarghese

Updated on September 18, 2022

Comments

  • AVarghese
    AVarghese almost 2 years

    I have Lubuntu 12.04 (64bit) with VirtualBox 4.2 installed and the setup below:

    1. eth0 adapter connected to LAN (having static IP 192.168.0.1 and it is the default gateway).
    2. ISC DHCP server listening on eth0, to configure PCs (in LAN) with dynamic IPs.
    3. ppp0 adapter (wirless Mblaze USB modem) to connect to Internet.
    4. eth0 has NATed to ppp0, so that all PCs connected to the LAN can have Internet.
    5. vboxnet0 host only network (selected for the Virtual Machines).

    Setup before bridging

    I would like to have a bridge combining vboxnet0 and eth0 to make it a single network (say br0) and have the DHCP server serve IPs through this new bridge. br0 now should take the static IP of eth0, so that the bridge can be the new gateway.

    Please note I neither need Bridged Adapter nor NAT solution in VirtualBox setting UI. I would like to configure all these manually editing all the associated configuration files.

    Any help deeply appreciated. Thanks in advance.