Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Ubuntu 13.04 host running VirtualBox 4.2.12. This host has both a wired and a wireless network interface, but only one of which would usually be active at any given time. For example, at home wireless would be active, and at office wired one would be active.

Now, I would like to set up a Fedora 18 VirtualBox guest in "Bridged Networking" mode in such a way that the guest and the host can freely ssh to each other (and to the network that the host is connected to) using their static IPv4 addresses. And if I add more such guests in future, then the guests should also be able to ssh to each other.

However, I'm facing the following problems:

  1. Upon selecting "Bridged Networking" mode for the guest in VirtualBox settings, the guest ends up getting a dynamically assigned, IPv6 address (whereas I want a statically assigned address that is an IPv4 address).

  2. When the wireless interface is active on the host, I get to see only the "lo" and the "wlan0" entries in the output if ip addr on the host. So, the static IPv4 address that I assigned to the host's p2p1 (or, the wired) interface when it was active earlier in the day (in office) simply cannot be seen when the wired interface is not active later (at home).

  3. I tried the instructions given here (using the ifcfg-p2p1 file for my case), but they didn't work for me. For example, I was able to stop and disable NetworkManager.service just fine, but I could not restart network.service (it gave me the error "Restarting network (via systemctl): Job for network.service failed. See 'systemctl status network.service' and 'journalctl -n' for details."

Also,

  1. Is there any distribution-independent way to assign static IPv4 address to my F18 VM? Meaning, since each Linux distro keeps its network settings in different file/dir structures (and with maybe different properties too inside), is there any way I can achieve the above setup via commands like ifconfig, ip, route, etc and then also be able to persist their changes to whatever files those changes need to go in?

  2. To avoid problem #2 above, do I have to use a manually created tun/tap device to use for "Bridged Networking"? If so, how can I do that on Ubuntu 13.04?

share|improve this question
add comment

1 Answer 1

If you want a network that's shared between host and guest(s) that is not impacted by other network changes, you can create a host-only network and map a 2nd network card in the VM to it. Your 1st network card provides the internet connectivity and your 2nd network card provides the communication amongst guest(s) and host:

  1. In host VirtualBox, go to File...Settings...Network and create a Host-only network with default settings. This is in the settings for VirtualBox as a whole, not any specific VM.
  2. In host VirtualBox settings for your VM, go to Network and click the "Adapter 2" tab (your Adapter 1 settings can remain as Bridged).
    1. Click the "Enable Network Adapter" box
    2. In the "Attached to:" dropdown, select "Host-only Adapter"
    3. In the "Name:" dropdown, select the host-only network you created earlier (e.g. "vboxnet0")
  3. Boot up the VM and go to your network settings. You should see a 2nd network adapter show up.
  4. Assign it a static IP address in the same subnet as the one it received automatically from the host-only network's DHCP. I believe by default VirtualBox host-only network hands out DHCP addresses .101 and higher, so you could assign a static address somewhere between .2 and .100.
  5. Repeat steps 2-4 for any future VMs you want added to this same network.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.