New Look. New CentOS!

Yes, that’s what CentOS 7 says. Anyway, lately I installed CentOS 7 over VMware and installation were quite smooth. Immediate after installation, I tried to browse some web and it was failing. While doing basic troubleshooting, I noticed there were no IP when I did ifconfig.

In this article, I will talk about how to fix if you don’t get the Internet on VMware with CentOS 7.

[[email protected] ~]$ ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 
ether 00:0c:29:68:22:e2  txqueuelen 1000  (Ethernet) 
RX packets 0  bytes 0 (0.0 B) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 0  bytes 0 (0.0 B) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536 
inet 127.0.0.1  netmask 255.0.0.0 
inet6 ::1  prefixlen 128  scopeid 0x10<host> 
loop  txqueuelen 0  (Local Loopback) 
RX packets 642  bytes 55820 (54.5 KiB) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 642  bytes 55820 (54.5 KiB) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[[email protected] ~]$

That leads me to think either network adaptor is not enabled or failed to obtain DHCP IP address.

Quick Solution 

  1. Access terminal/console
  2. Become a root if you are not already
  3. Execute “dhclient –v” command
  4. You will notice it will bound IP address (certainly not as shown here) as shown below
[[email protected] network-scripts]# dhclient -v
Internet Systems Consortium DHCP Client 4.2.5 Copyright 2004-2013
Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/ens32/00:0c:29:68:22:e2
Sending on   LPF/ens32/00:0c:29:68:22:e2
Sending on   Socket/fallback DHCPDISCOVER on ens32 to 255.255.255.255 port 67 interval 4 (xid=0x433a9e33) DHCPREQUEST on ens32 to 255.255.255.255 port 67 (xid=0x433a9e33)
DHCPOFFER from 172.16.179.254 DHCPACK from 172.16.179.254 (xid=0x433a9e33) bound to 172.16.179.136 -- renewal in 822 seconds.
[[email protected] network-scripts]#

5.     Boom, that’s all, you should have the Internet now. You will also notice IP when you do ifconfig.

[[email protected] network-scripts]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 
inet 172.16.179.136  netmask 255.255.255.0  broadcast 172.16.179.255 
ether 00:0c:29:68:22:e2  txqueuelen 1000  (Ethernet) 
RX packets 11  bytes 1255 (1.2 KiB) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 23  bytes 3536 (3.4 KiB) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536 
inet 127.0.0.1  netmask 255.0.0.0 
inet6 ::1  prefixlen 128  scopeid 0x10<host> 
loop  txqueuelen 0  (Local Loopback) 
RX packets 770  bytes 66956 (65.3 KiB) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 770  bytes 66956 (65.3 KiB) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Add this in auto-startup

You might be interested in putting this in auto-startup so you don’t have to do this every time you start the CentOS VM. This is how you can put the script in auto-startup so it starts automatically after VM is rebooted.

  • Go to /etc/init.d
  • Create a file with following, I have kept the name as “net-autostart
#!/bin/bash
# Solution for "No Internet Connection from VMware"
#
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
dhclient -v
  • Save the file
  • Change the file permission as executable
chmod 755 net-autostart
  • Add this script for auto-start using chkconfig command
chkconfig --add net-autostart
  • Restart VM to test

I hope this helps. Let me know how it goes with you.

Reader Interactions

Comments

  1. I had the same probnlem when first starting centos 7 on vmware. No network connection.
    I found the right solution, instead of scripting around it I just switched on the network interface in the network settings (desktop, upper bar, left of day/time field). Maybe this is intended behaviour to prevent the system from going online before it’s configured correctly.

  2. This worked for me two days ago, I didn’t save it to the bash, so when I started my vm today, there is no Internet again.

    I then proceed to run the same command again, but this time no more magic.

    Why? Can you sort it out? Thank you so much.

  3. Thanks a lot for your post. Its worked for internet connection as well as to establish communication between host and guest machine. I broke my head for this with many IP configurations.

Comments

Your email address will not be published. Required fields are marked *