0

I tried a lot guides but nothing didn't really help/ worked (for) me. What I would like to do is to host a server in my local network with a static IP. I have a Linux Mint VM inside Virtualbox which is configurated with a specific IP (192.168.0.30), but I don't get the specific IP (because at the moment I get a dynamic IP). How can I edit this? Tried Host-only-Adapter etc but it didnt't worked at all. I also would like to have internet access with the server. So the server hosts but can also browse the internet.

Hope somebody can help me ;)

Greets

EDIT (to clearify):

I have Virtualbox on my Windows 8.1 PC.

A Linux VM (Linux Mint) is running in Virtualbox.

Right now the VM network is configured as "bridged".

Works fines, I can ping the VM and I can ping my host from my VM. (Full connection between both).

What I want to change now:

The VM gets sometimes another IP. I configurated the VM with 192.168.0.30 but now the router gave me 192.168.0.20 which causes problems, because my owncloud (runs on apache) is configurated with the 192.168.0.30 adress.

I would like to give the VM a static IP adress (192.168.0.30), so that every time I start the VM the VM always gets the IP adress 192.168.0.30.

How can I do that?

What do I have to change?

EDIT 29.11.15

Here the interfaces file:

 # The loopback network interface
   auto lo
   iface lo inet loopback

 # The primary network interface

 auto eth0
 iface eth0 inet static
 address 192.168.0.30
 netmask 255.255.255.0
 gateway 192.168.0.1

VM has Internet connection (e.g. via Iceweasel) but ifconfig still tells me another IP adress (e.g. right now I got the 192.168.0.20).

Must I change some settings inside Virtualbox? VM is right now running with bridged.

  • You want to have a guest in your host network and 192.168.0.30 is host network IP address? Seems like bridged networking https://www.virtualbox.org/manual/ch06.html#network_bridged to me. If not try to expand your question a little... – g2mk Nov 28 '15 at 22:01
  • Edited it, hope you understand now what I mean ;) – Konstantin Nov 28 '15 at 22:38
  • 1
    Possible duplicate of [How do I setup a virtualbox server with a static ip?](http://superuser.com/questions/357120/how-do-i-setup-a-virtualbox-server-with-a-static-ip) – Tom Zych Nov 29 '15 at 00:11
  • Already tried it but with host-only networking I can't work and if I change the seetings I get no connection. – Konstantin Nov 29 '15 at 00:21

2 Answers2

1

@Konstantin

Set Static IP to Linux VM (Linux Mint) is running in Virtualbox.

can you try the below process

Step 1 : take backup of the file interface
sudo cp /etc/network/interfaces /etc/network/interfaces-bk

Step 2: edit the file interfaces as follows sudo vi /etc/network/interfaces

     # The loopback network interface
       auto lo
       iface lo inet loopback

     # The primary network interface

     auto eth0
     iface eth0 inet static
     address 192.168.1.21
     netmask 255.255.255.0
     gateway 192.168.1.1

Step3 : restart the network services sudo /etc/init.d/networking restart

  • Tried it. Connection works (VM has access to the Internet with Iceweasel) but the IP is still another one. More Info in my post above. – Konstantin Nov 29 '15 at 16:39
0

You have got two options:

  • Setup your router to permanently assign 192.168.0.30 IP address from DHCP to your VM guest (probably binding of MAC address to IP address in router LAN -> DHCP configuration).
  • Setup 192.168.0.30 or other IP address on your VM guest statically. Select IP outside of DHCP range, but still inside your network (192.168.0.x or 192.168.x.x I guess).

In your case:

  • 192.168.0.30 isn't a good candidate for static IP address - it is inside DHCP range, so select a different one outside DHCP range or adjust DHCP range.
  • Keep Bridged Adapter settings in your VM network configuration.
  • Set-up static IP address on your guest OS in a way you prefer: edit /etc/network/interfaces, or through your desktop environment GUI. You might copy mask, gateway ifconfig and DNS servers cat /etc/resolv.conf information from current dynamic NIC setup.
  • Restart your network interface.
g2mk
  • 1,428
  • 12
  • 15
  • I think the first idea would be the best. However how does the second thing exactly work? I need to extract the VM later and open it on my laptop because the server should work in another network too. I would go to another place and just start the server. Is this possible? So it would be better to do the settings in a different way (no router configuration). – Konstantin Nov 29 '15 at 00:22