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.
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
To find the gateway
route -n | grep "^0.0.0.0" | 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