I have installed Oracle Linux 6.5 (minimal installation) on a virtual machine created on VMware vSphere 5.5. I have tried to configure dhcp during the installation by editing IPv4 Settings of System eth0 to use Automatic (DHCP) but somehow it does not work.
Then I changed the ifcfg-eth0 to use static ip address and that works.
Here is the content of /etc/sysconfig/network:
Here is the content of /etc/sysconfig/network-scripts/ifcfg-eth0 using static ip address:
Based on my understanding, I should able to use dhcp by changing ifcfg-eth0 (I commented the parameters not needed for dhcp by adding #) but I have tried the following ifcfg-eth0 and it does not work:
I have also tried to add GATEWAY=##.##.###.### to /etc/sysconfig/network but that does not help.
I have checked that dhclient package is installed by using rpm -qa dhclient.
I'm new to Linux.
Thanks for any help
If this is your first experience with Oracle Linux, I recommend you perform a default installation instead of going minimal, which is just going to make things more difficult for no good reason. Enterprise Linux is not MS Windows and the difference between default and minimal installations do not compare.
You also do not want to use the rpm utility to install any software and use yum instead. The yum utility is standard. Rpm does not resolve software dependencies.
Your ifcfg-eth0 script is missing the line that specifies to use DHCP:
You can also use the network configuration utility, even in text mode, by typing the following at the command prompt of root:
If the above utility is not installed:
yum install system-config-network-tui
You will have to configure an appropriate yum repository file. The process is explained in the Oracle Linux release notes:
See 3.2.3. About Oracle Linux Installation Media
Then insert the DVD or attach the DVD iso image to your virtual machine and mount it as following:
mkdir -p /media/ISOimage
mount /dev/cdrom /media/ISOimage
The path "/media/ISOimage" should be the same as you specified in the yum repository file.
After that you can use the yum utility to list or install software.
Your config seems fine - the BOOTPROTO entry says DHCP.
For VMs I suggest not using settings such as HWADDR and UUID. Unlike real iron, one can easily (and accidentally) reset the MAC addresses of virtual NICs. And render your guest o/s network settings invalid as these no longer refer to the correct VM h/w.
I would test DHCP with the following basic settings only:
And use ifconfig (or ifup and ifdown) to test it, while keeping an eye on /var/log/messages.
How is the virtual NIC defined on the host o/s? I prefer bridge mode as that makes the VM just another piece of h/w on the subnet.
I have found out that there is no dhcp server set up in the subnet. The /var/log/messages has "DHCPDISCOVER" entries and "No DHCPOFFERS received" entry but I don't think those entries indicate no dhcp server. Originally, I thought either I have configured ifcfg-eth0 incorrectly or dhcp server is out of addresses to assign. I want to know whether any log in the virtual machine TESTOL will indicate no dhcp server. Also, what will be the log entry if a dhcp server is out of addresses to assign? When I google about dhcp, I see the entry "No working leases in persistent database - sleeping", does that mean out of addresses or something else?
Thanks for all the help.
DHCP discovery happens at the network link layer using UDP and does not require a pre-existing TCP/IP subnet configuration on the host system.
In a VM environment a DHCP server is typically provided by your VM software that provides automatic routing between a certain virtual machine network adapter type and the host system. I suggest you verify that you are using the correct vm network adapter type and correct MAC address in your config files. There may be some VMware Spere network specific issues, which are however beyond of the scope of this forum.
My suggestion is as follows. Cut and paste or type the following exactly as shown to your root command prompt:
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
rm -f /etc/udev/rules.d/70-persistent-net.rules
shutdown -r now
After that your eth0 adapter should be assigned a DHCP based address, provided you configured the correct VM network adapter or DHCP is assigned by your host network. I tested the above Oracle Linux 6.5 and it works.
If you do not have a DHCP server on the subnet that the VM connects to, then no DHCP address will be offered. You need a DHCP/BootP relay (RFC 1542) on that subnet to relay the DHCP client broadcast to the subnet on which the DHCP server resides. Routers can be configured to this effect.
If there is a DHCP server and your DHCP client does not get an address - that could be to MAC bindings, where the DHCP server is configured with static IP allocation to MAC addresses.
In addition to all the very good technical information you've already received, I'd like to point out that often the solution to a problem is to question the premise.
In this case, that means asking why you want to configure for dhcp in the first place. Running a server with a DHCP assigned IP address is like running a business that changes it's phone number every day ..... how do you expect clients to locate it when the address keeps changing?