Facebook
Twitter
LinkedIn
YouTube
GitHub
Hasan's Blog
  • Home
    • About me
  • Hashicorp
  • Ansible
  • CI/CD
  • DevOps

Solved – How to fix Internet connection Issue in Linux CentOS 7 Quickly

2020/03/18Hasan YousufUncategorized

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

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

Are you in the same situation like 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 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 as shown below
[root@localhost 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.
[root@localhost network-scripts]#

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

[root@localhost 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.

Previous post How to setup network after RHEL/CentOS 7 minimal installation Next post How to navigate long commands faster

Categories

  • Casperjs (1)
  • CI/CD (4)
  • DevOps (6)
  • Gruntjs (2)
  • Jira (1)
  • Linux (1)
  • Programming (1)
  • Uncategorized (14)
  • VMware (1)

Archives

  • May 2020 (1)
  • April 2020 (1)
  • March 2020 (2)
  • September 2019 (2)
  • May 2018 (1)
  • September 2017 (3)
  • July 2017 (1)
  • June 2017 (4)
  • May 2017 (1)
  • July 2015 (2)
  • January 2015 (1)
  • October 2014 (1)
  • September 2014 (5)
  • August 2014 (1)

Tags

Arduino Arduino sketch Arduino sketch upload bash shell casperjs Couchdb Curl docker container docker images github Gitlab gnu Parallel gruntjs JAVA JAVA jenkins Jira JPA Json Linux linux mint Maven mint MYSQL Tomcat Ubuntu Version Control xpath
  • Home
    • About me
  • Hashicorp
  • Ansible
  • CI/CD
  • DevOps
@2017
Manage Cookie Consent
We use cookies to optimize our website and our service.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Preferences
{title} {title} {title}