Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to find the gateway and DNS IPs in a DHCP configured network in CentOS? I'm using CentOS installed in vmware using NAT connection and I want to make the ip static.

share|improve this question
up vote 5 down vote accepted

Will show the Interfaces, along with IP address. Normally, but not always eth0 will be the Interface you are looking for.

To find the DNS

cat /etc/resolv.conf

To find the gateway

route -n | grep "^" | tr -s " " | cut -f2 -d" "

What you are saying about "wanting to make the IP static" scares me a bit. It would be wrong to take the dynamically assigned IP address and hard code it as a static as it will confuse the server. What you should do is either take another IP address in the same range - but one outside the range the DHCP server is assigning. An alternative is to modify the DHCP server to dynamically hand out static IP addresses if supported by your DNS server. If your DHCP server is ISC DHCP and you have access to do it, you can modify the config at /etc/dhcp3/dhcpd.conf with a bit like

   host hostname {
            hardware ethernet MAC.ADDR;
            fixed-address FIXED.IP.ADDR.HERE;                
share|improve this answer
Thanks. It seems you've misspelled ifconfig. I don't know why my resolv.conf was empty before. when I changed it turned back to dhcp again and restarted the network, it has the dns server now. I don't use ISC DHCP, is there a way to do it with the CentOS dhcp? – Mohsenme Sep 2 '13 at 7:31
Are you sure the CentOS dhcp is not the ISC one ? (It is for the servers I maintain, but you might be using something else like DNSMasq) You can possibly check it by running /usr/sbin/dhcpd --version – davidgo Sep 2 '13 at 7:39
Yes I see an empty /etc/dnsmasq.d directory but not /etc/dhcp3 directory. – Mohsenme Sep 2 '13 at 7:42
I finally found the dhcp settings under the host operating system at C:\ProgramData\Vmware\vmnetdhcp.conf – Mohsenme Sep 2 '13 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .