Nouveau look. Nouveau CentOS!
Oui, c'est ce que dit CentOS 7.
Quoi qu'il en soit, ces derniers temps, je installé CentOS 7 sur VMware, et l'installation était assez fluide. Immédiatement après l'installation, j'ai essayé de naviguer sur le Web, et cela échouait.
Lors du dépannage de base, j'ai remarqué qu'il n'y avait pas d'adresse IP lorsque je l'ai fait 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 ~]$
Êtes-vous dans la même situation que moi?
Dans cet article, je vais vous expliquer comment réparer si vous n'obtenez pas Internet sur VMware avec CentOS 7.
Cela m'amène à penser que la carte réseau n'est pas activée ou n'a pas réussi à obtenir une adresse IP DHCP.
Solution
- Terminal / console d'accès
- Devenez root si vous ne l'êtes pas déjà
- Exécuter
dhclient –v
commander - Vous remarquerez que l'adresse IP sera liée comme indiqué ci-dessous
[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]#
Boom, c'est tout, vous devriez avoir Internet maintenant. Vous remarquerez également IP lorsque vous faites 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
Cela pourrait vous intéresser Démarrage automatique, vous n'avez donc pas à le faire à chaque fois que vous démarrez la machine virtuelle CentOS.
C'est ainsi que vous pouvez mettre le script en démarrage automatique, afin qu'il démarre automatiquement après le redémarrage de la VM.
- Accédez à /etc/init.d
- Créez un fichier avec suivant, j'ai gardé le nom comme "net-démarrage automatique"
#!/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
- Enregistrer le fichier
- Changer l'autorisation de fichier comme exécutable
chmod 755 net-autostart
- Ajoutez ce script pour le démarrage automatique en utilisant
chkconfig
commander
chkconfig --add net-autostart
- Redémarrez la VM pour tester
J'espère que ça aide.
Si vous souhaitez maîtriser les compétences en administration Linux, consultez ceci cours.