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

[[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] ~]$

Are you in the same situation as I was?

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

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

Solution 

  • Access terminal/console
  • Become a root if you are not already
  • Execute dhclient –v command
  • You will notice it will bound IP address 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]#

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.

If interested in mastering Linux Administration skills then check out this course.