Static IPs in CentOS guests

Discussions about using Linux guests in VirtualBox.
Post Reply
matrix_cal
Posts: 5
Joined: 24. Jul 2010, 14:05
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux

Static IPs in CentOS guests

Post by matrix_cal »

Hi,
I am trying to test linux HA using virtualbox. I am trying to assign static IP to my vm so that IP does not get changed .
Configuration so far :-

1) Base machine is running on MacOS which has Nat Networks and Host-Only Networks.
2) Host-only Network has dhcp server running.
3) Guest machine is running CentOS 6.4 with two Adapters - Adapter-1 with NAT and Adapter-2 with Host-only Adapter

I am able to access internet as well local network.
As i progress, i would like to assign STATIC IP address to guest OSes so that i can configure other services.

I am aware of one way of assigning static IP,that is by hacking /etc/sysconfig/network-scripts/eth0 and changing some param ( what all , i need to find out) .

Do we have any better and standard way of achieving this ?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Static IPs in CentOS guests

Post by Perryg »

I don't know why you would call it hacking. That is the way to setup the network. Google set static ip centos.
matrix_cal
Posts: 5
Joined: 24. Jul 2010, 14:05
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux

Re: Static IPs in CentOS guests

Post by matrix_cal »

Perryg wrote:I don't know why you would call it hacking. That is the way to setup the network. Google set static ip centos.
There are two ways of setting IP addresses. Static and dhcp. Virtualbox supports dhcp and we are not expected to change anything in guest level for it. In the same way, i was searching for static ip.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Static IPs in CentOS guests

Post by socratis »

That's because getting a DHCP address is the default on most guest OSes. If you want to assign a static IP, you are expected to change things.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
matrix_cal
Posts: 5
Joined: 24. Jul 2010, 14:05
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux

Re: Static IPs in CentOS guests

Post by matrix_cal »

socratis wrote:That's because getting a DHCP address is the default on most guest OSes. If you want to assign a static IP, you are expected to change things.
Thanks
I am trying to setup Linux HA test setup. So i will need two NICs on each guests . Eth0 will get IP from DHCP(NAT) while i will assign static private IP to eth1(Host Only) which should be routable inside 192.168.56.XXX network.

1) How can i find out default gateway and dns servers for eth0?
2) Where can i define default GW for 192.168.56.XXX network ?

I think i will need to remove DNS entries from eth1 config as there is no dns server running in 192.168.56.XXX network.I will start with /etc/hosts file.

Do linux gurus see any thing missing here ? I need to configure in such a way that VM can ping google.com as well as to other VMs.

Thanks in advance for helping and guiding me.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Static IPs in CentOS guests

Post by Perryg »

There is no gateway ( nor is it needed ) for host-only.
A gateway is only required "if" you need access to the Internet and since host-only prevents this... well you get the point.
matrix_cal
Posts: 5
Joined: 24. Jul 2010, 14:05
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux

Re: Static IPs in CentOS guests

Post by matrix_cal »

Perryg wrote:There is no gateway ( nor is it needed ) for host-only.
A gateway is only required "if" you need access to the Internet and since host-only prevents this... well you get the point.
Thanks for the clarification. But we will be needing Internet access but via different adapter.

1)Adapter 1 --->NAT--> eth0--->dhcp
2) Adapter 2-->Host Only -->eth1-->Static IP (Without default GW)

Above setup should get access internet via eth0 and internal network via eth1.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Static IPs in CentOS guests

Post by Perryg »

I know that. I saw the NAT and since that will access the Internet you are fine leaving it alone. The second host-only will setup a communication link between the guests and host. Now if the host does not need to play into the scheme use internal for the second adapter instead.
matrix_cal
Posts: 5
Joined: 24. Jul 2010, 14:05
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux

Re: Static IPs in CentOS guests

Post by matrix_cal »

Perryg wrote:I know that. I saw the NAT and since that will access the Internet you are fine leaving it alone. The second host-only will setup a communication link between the guests and host. Now if the host does not need to play into the scheme use internal for the second adapter instead.
Thank you so much.I will read more on internal adapter.
Let me take the opportunity of your attention in this thread.

Can you please confirm if i can build up Linux Cluster using Host Only Adapter or should i go for Internal ?

Thanks once again.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Static IPs in CentOS guests

Post by Perryg »

I prefer the internal mode myself. This will isolate the cluster and anything that you would want to do from the host. But this depends on exactly what you are going to do with the cluster. testing IMHO should always be isolated.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Static IPs in CentOS guests

Post by socratis »

Perryg wrote:There is no gateway ( nor is it needed ) for host-only.
Aha! But, there is a subtle difference, at least in Windows7, and how it identifies the network connections. If there is no gateway the network location is identified as "Unidentified Network" and you cannot change firewall options, rename it, etc.

I am thinking of opening a bug-tracker issue. I hope that I'm not hijacking the thread...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Static IPs in CentOS guests

Post by Perryg »

socratis wrote:
Perryg wrote:There is no gateway ( nor is it needed ) for host-only.
Aha! But, there is a subtle difference, at least in Windows7, and how it identifies the network connections. If there is no gateway the network location is identified as "Unidentified Network" and you cannot change firewall options, rename it, etc.

I am thinking of opening a bug-tracker issue. I hope that I'm not hijacking the thread...
I hope you mean to open the bug at Windows. This is after all their problem due to the way they view networks.

There is a way to fix it as well and it requires editing the registry. Search the Internet and you will find it.
Post Reply