Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save swuecho/42426a4a5e4d25c4779af3375e98894a to your computer and use it in GitHub Desktop.

Select an option

Save swuecho/42426a4a5e4d25c4779af3375e98894a to your computer and use it in GitHub Desktop.

Revisions

  1. @pjdietz pjdietz revised this gist Jun 24, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -52,4 +52,5 @@ Add a line that starts with the static IP address for the guest, followered by w
    192.168.56.101 myguest.home.local www.mycoolsite.com anyother.fakesite.com
    ```


    Source:
    http://christophermaier.name/blog/2010/09/01/host-only-networking-with-virtualbox
  2. @pjdietz pjdietz revised this gist Jun 24, 2013. 1 changed file with 35 additions and 7 deletions.
    42 changes: 35 additions & 7 deletions Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,55 @@
    Add a host-only adapter to the VM in VirtualBox.
    # VirtualBox Host-Only Static IP

    My typical setup for a development box in [VirtualBox](https://www.virtualbox.org/) uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

    To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

    Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

    ### Temporary

    On the client, setup eth1 to use a static IP address temporarily.
    To get the static IP address working temporarily, access the termainal on the client, and enter the following to assign a static IP to eth1. (I'm assuming 192.168.56.101 because that's VirtualBox's default. Make sure it matches the IP for your host-only adapter.)

    ```bash
    $ ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
    # On GUEST: Temporarily assign a static IP to eth1
    ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
    ```

    ### Persistent

    To make this change permanent, add the following to **/etc/network/interfaces**
    The last command should work until you have to restart the virtual machine. To make the change persistent, you'll need to modify **/etc/network/interfaces**

    ```bash
    $ sudo nano /etc/network/interfaces
    # On GUEST: Modify the configuration file
    sudo nano /etc/network/interfaces
    ```

    ```
    Add the following to configure eth1 to use a static IP address and come up when the system starts.

    ```bash
    # The host-only network interface
    auto eth1
    iface eth1 inet static
    address 192.168.56.101
    netmask 255.255.255.0
    network 192.168.56.0
    broadcast 192.168.56.255
    ```
    ```

    ### Accessing the Guest from the Host

    Finally, you'll probably want to add some names to your host machine's **/etc/hosts** file. Make sure to add each hostname you will use on your guest.

    ```bash
    # On HOST: edit /etc/hosts
    sudo nano /etc/hosts
    ```

    Add a line that starts with the static IP address for the guest, followered by whitespace, then each of the hostnames that should point to your guest.

    ```bash
    # Inside /etc/hosts on your HOST
    192.168.56.101 myguest.home.local www.mycoolsite.com anyother.fakesite.com
    ```


  3. @pjdietz pjdietz revised this gist Jun 12, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    Add a host-only adapter to the VM in VirtualBox.

    ## Temporary
    ### Temporary

    On the client, setup eth1 to use a static IP address temporarily.

    ```bash
    $ ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
    ```

    ## Persistent
    ### Persistent

    To make this change permanent, add the following to **/etc/network/interfaces**

  4. @pjdietz pjdietz revised this gist Jun 12, 2013. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    # Virtual Box Host-only Adapter with Static IP Address on Ubunutu Guest

    Add a host-only adapter to the VM in VirtualBox.

    ## Temporary
  5. @pjdietz pjdietz revised this gist Jun 12, 2013. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,18 @@
    Virtual Box Host-only Adapter
    -----------------------------
    Add a host only adapter to the VM in VirtualBox
    # Virtual Box Host-only Adapter with Static IP Address on Ubunutu Guest

    Add a host-only adapter to the VM in VirtualBox.

    ## Temporary

    On the client, setup eth1 to use a static IP address temporarily.

    ```bash
    $ ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
    ```

    To make this change permanent, add the following to **/etc/network/interfaces***
    ## Persistent

    To make this change permanent, add the following to **/etc/network/interfaces**

    ```bash
    $ sudo nano /etc/network/interfaces
  6. @pjdietz pjdietz created this gist Jun 12, 2013.
    24 changes: 24 additions & 0 deletions Virtual Box Host Only Static IP.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    Virtual Box Host-only Adapter
    -----------------------------
    Add a host only adapter to the VM in VirtualBox
    On the client, setup eth1 to use a static IP address temporarily.

    ```bash
    $ ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up
    ```

    To make this change permanent, add the following to **/etc/network/interfaces***

    ```bash
    $ sudo nano /etc/network/interfaces
    ```

    ```
    # The host-only network interface
    auto eth1
    iface eth1 inet static
    address 192.168.56.101
    netmask 255.255.255.0
    network 192.168.56.0
    broadcast 192.168.56.255
    ```