-2

I have been trying for months on how to change DHCP to STATIC ip successfully on Centos VM

The thing is i am not sure if it is because i am using a virtual machine or if the host bridge network is affecting things but when i change DHCP to STATIC following all i should (i have searched everywhere on the net even video too http://www.youtube.com/watch?v=V3ymaozVntU and still no solution) i do get STATIC ip but i can only ping localhost and the static ip address nothing more..i cannot ping gateway or outside address

what is going on? what am i doing wrong?

I have been trying this thing for like 5 months now and have never gotten this thing.

This is the config:

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=00:30:48:56:A6:2E
IPADDR=192.168.1.25
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
ONBOOT=yes

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=vm2.system.com
GATEWAY=192.168.1.1

$ cat /etc/resolv.conf
search system.com
nameserver 192.168.1.1

$ cat /etc/hosts
127.0.0.1    vm2.system.com localhost
::1          localhost
192.168.1.25 vm2.system.com system.com

$ route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

Chris S
  • 77,337
  • 11
  • 120
  • 212
redhatengineer6
  • 79
  • 2
  • 5
  • 9
  • How are you configuring ifcfg-eth0 (or whatever interface you are using), can you add the config to your question? – NickW Apr 29 '13 at 08:22
  • i pretty much followed everything i setup everything same way as video http://www.youtube.com/watch?v=V3ymaozVntU and even http://rojanu.wordpress.com/2012/10/06/linux-static-ip-address-configuration/ – redhatengineer6 Apr 29 '13 at 08:25
  • What IP, netmask and gateway are you using, who gave the values to you, and are they similar to the DHCP values? – NickW Apr 29 '13 at 08:28
  • @NickW i added them above...i mean i made up the values myself – redhatengineer6 Apr 29 '13 at 08:31
  • What VM you are using I mean Sun Virtual BOX or VMWARE or anything else? have you changed your VM to use bridging mode? – Abhishek Anand Amralkar Apr 29 '13 at 09:25
  • @redhatengineer6 you say you made them up? Do you have a network guy in your office? You should probably obtain the IPs from someone responsible. Otherwise, you need to make sure that the gateway `192.168.1.1` exists, as does the NS server, etc. – NickW Apr 29 '13 at 09:28
  • @abhishek-amralkar i am using KVM and yes it is in bridge mode – redhatengineer6 Apr 29 '13 at 09:29
  • @NickW this is practice for the RHCSA exam and no this is not an office setup...i am just practicing with the Centos VM on my KVM host machine...i have tried different gateway..you name it..and i am sure the gateway exists...i mean how can i tell it exists? – redhatengineer6 Apr 29 '13 at 09:31
  • have you checked your CentOS Firewall(iptables) ? – Abhishek Anand Amralkar Apr 29 '13 at 09:34
  • OK, that's fine, you just need to ensure that the network you want to connect to is configured :) – NickW Apr 29 '13 at 09:37
  • @NickW network is configured? well how? – redhatengineer6 Apr 29 '13 at 09:54
  • @abhishek-amralkar can you tell me what i should be looking at? because i mean firewall for what ports or what do i look for? – redhatengineer6 Apr 29 '13 at 09:55
  • That other machines work on it, and so forth, there's no point in trying to connect to a network that is non functional. – NickW Apr 29 '13 at 09:56
  • From your server run below command and see if your internet works or not service iptables stop.. – Abhishek Anand Amralkar Apr 29 '13 at 10:06
  • @abhishek-amralkar for some reason i did service `iptables stop` and i was able to ping gateway...and when i did `service iptables start` i was still able to ping gateway..this is surprising to me...but i cannot ping outside urls...like `ping google.com` isn't work...i got `ping: unknown host google.com` – redhatengineer6 Apr 29 '13 at 10:18
  • @NickW when it is DHCP it works all fine no problem at all...could browse using firefox and all...so i guess network is fine? – redhatengineer6 Apr 29 '13 at 10:20
  • If the values assigned are the same (except for the IP on your redhat machine) I'd say yes. – NickW Apr 29 '13 at 10:21
  • @NickW not sure what you mean...i mean there are so many IP adresses i can use why use same as previous by DHCP? well i did use same IP as DHCP couple of times too and still had problems...i watched and followed this video http://www.youtube.com/watch?v=V3ymaozVntU and the guy was able to ping gateway and ping google.com and i can't – redhatengineer6 Apr 29 '13 at 10:26
  • I mean the IPs of the gateways, NS servers and netmask. What errors do you get when you try and ping google? – NickW Apr 29 '13 at 10:29
  • @NickW `ping google.com` isn't working...i got `ping: unknown host google.com`...also how do i know what IPs, gateways and nameservers to use? i mean in the setup i have isn't that good?...also how can i ping google.com when there is no internet connection? that is weird to me..i saw in that youtube video..the video did ping yahoo.com without internet connection..how is that? – redhatengineer6 Apr 29 '13 at 11:43
  • If the settings are the same as they are when you use DHCP, they will be fine. Can you ping the gateway (192.168.1.1 ?) – NickW Apr 29 '13 at 11:46
  • @NickW check i added `route -n` and yes now i can ping gateway...remember the "no network connection" shows for the icon on the top right corner because in ifcfg-eth0 remember networkmanager is set to NO...so how possible can one `ping google.com`? how does that process work..where is the connection coming from? – redhatengineer6 Apr 29 '13 at 11:54
  • That's a pretty hefty question. Basically, if you can now ping your gateway, you need to ensure that your DNS server is configured, you might want to follow ewwhite's advice, (he knows what he is talking about). Basically, you ask your DNS server what www.google.com translates to, then you send IP packets to that address. What is the route you added? – NickW Apr 29 '13 at 12:00
  • @NickW check the question..i edited it...what do you mean by DNS server?...i mean did you watch that youtube video? I just want to do exactly what he did and never did anything like DNS server – redhatengineer6 Apr 29 '13 at 12:08
  • In `/etc/resolve.conf` you have a line `nameserver 192.168.1.1`, if that server exists, good, if not, change it to `nameserver 8.8.8.8` – NickW Apr 29 '13 at 12:10
  • @NickW just checked and it disappears – redhatengineer6 Apr 29 '13 at 12:13
  • You need to do what ewwhite says then! – NickW Apr 29 '13 at 12:13
  • @NickW yes you did it!!!...Thanks!!!i can now ping google.com now that i added `nameserver 8.8.8.8`..thats crazy..i have tried and tried and tried and never figured this thing out – redhatengineer6 Apr 29 '13 at 12:14
  • Glad to hear it, now you need to start studying the options we had you configure more in depth! – NickW Apr 29 '13 at 12:23
  • Now that your question is closed, edit it so that it can be reopened. As it stands, the question is very difficult to follow and does not include enough information to determine what's going on. See [How can I ask better questions on Server Fault?](http://meta.serverfault.com/q/3608/126632) for more information. – Michael Hampton Apr 29 '13 at 17:42
  • @redhatengineer6 Editing rants into posts doesn't garner much respect. Five [sf] community members closed your question, not moderators (who aren't employees) and not any employee of [SE] either. [SF] is for System Administrator (et al) only; it is not for people learning these topics; that much is explicitly covered by the [FAQ]. At best this question is posted on the wrong site ([unix.se] looks relevant, but you should read their FAQ first) - but the complete lack of detail (what you tried, what happened, errors, etc) makes this more "not a real question" than anything. – Chris S Apr 29 '13 at 18:11

1 Answers1

1

If this is EL6, stop the "NetworkManager" service if it's enabled.

Then run system-config-network-tui to configure your values.

Restart networking once you're done. service network restart

Also see: What is the relation between NetworkManager and network service in Fedora/RHEL/Centos?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • what about using command line and editing files? i tried using GUI and never got it to work either...i will like help on using command line so i can dissect what is going on..TUI won't help here either...there is something wrong somewhere and that is what i want to clear out – redhatengineer6 Apr 29 '13 at 11:55