Page 1 of 1

Static IPs in CentOS guests

Posted: 16. Nov 2013, 19:48
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 ?

Re: Static IPs in CentOS guests

Posted: 16. Nov 2013, 23:46
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 11:41
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 12:08
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 19:00
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 19:45
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 19:57
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 20:01
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 21:27
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.

Re: Static IPs in CentOS guests

Posted: 18. Nov 2013, 21:32
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.

Re: Static IPs in CentOS guests

Posted: 19. Nov 2013, 09:16
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...

Re: Static IPs in CentOS guests

Posted: 19. Nov 2013, 15:42
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.