LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-03-2018, 04:57 AM   #1
abukapsoun
LQ Newbie
 
Registered: Mar 2018
Posts: 11

Rep: Reputation: Disabled
I can ping IP but not hostname


Hi,

I have CentOS on virtualbox/ Windows 10. The network setting in the virutalbox is attached to: Bridged Adapter

In CentOS i can ping IPs, but not URLs. I tried setting 8.8.8.8 in resolv.conf but no luck. Can you please help me knowing why?

Below my config

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=04f8aba5-ee9f-425e-9333-4c9ed58b4d9b
DEVICE=enp0s3
ONBOOT=yes


[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 172.21.1.1 -----> IP address of my router
[root@localhost ~]#

[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@localhost ~]#

[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@localhost ~]#


Thanks,
 
Old 03-03-2018, 05:09 AM   #2
trognet
LQ Newbie
 
Registered: Feb 2018
Location: UK
Distribution: Slackware
Posts: 9
Blog Entries: 1

Rep: Reputation: Disabled
/etc/resolv.conf should contain the IP address of the name servers you wish to use, like this:

nameserver 194.168.4.123
nameserver 208.67.222.222
nameserver 158.152.1.43

I have no idea how things like systemD work with resolv.conf.
The intent of those who designed Unix networking was to have a simple text file that was easy to parse and contained the information needed.
I have always stuck to this and create my own resolv.conf and then made it immutable so nothing can change it, and things just work.
 
Old 03-03-2018, 05:19 AM   #3
abukapsoun
LQ Newbie
 
Registered: Mar 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi
I have tried adding 8.8.8.8 and 8.8.4.4 in the resolv.conf but it didnt work either
 
Old 03-03-2018, 05:22 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Duplicate reply

Last edited by jlinkels; 03-03-2018 at 05:24 AM.
 
Old 03-03-2018, 05:23 AM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
It must be a DNS thing. If you can ping a numeric IP only DNS can be failing.

Setting nameserver 8.8.8.8 in /etc/resolv.conf is sensible. But take into account that this file is overwritten every time a new DHCP address is issued. Very important.

Try to issue
Code:
dig www.google.com
and see which DNS server is being used. If any. If you don't have dig, try nslookup.

If no DNS server is used, stop the dhcp client (not sure how to do that on Centos) or use a fixed IP. Set resolv.conf to nameserver 8.8.8.8 and try again.

jlinkels
 
Old 03-03-2018, 07:59 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
never mind it is a broader spectrum then I thought.

Last edited by BW-userx; 03-03-2018 at 08:00 AM.
 
Old 03-03-2018, 08:36 AM   #7
abukapsoun
LQ Newbie
 
Registered: Mar 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
I cannot run dig, it is not installed. And since no name resolution i cannot run yum either

Quote:
Originally Posted by jlinkels View Post
It must be a DNS thing. If you can ping a numeric IP only DNS can be failing.

Setting nameserver 8.8.8.8 in /etc/resolv.conf is sensible. But take into account that this file is overwritten every time a new DHCP address is issued. Very important.

Try to issue
Code:
dig www.google.com
and see which DNS server is being used. If any. If you don't have dig, try nslookup.

If no DNS server is used, stop the dhcp client (not sure how to do that on Centos) or use a fixed IP. Set resolv.conf to nameserver 8.8.8.8 and try again.

jlinkels
 
Old 03-03-2018, 09:19 PM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Try
Code:
$ ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 35 Mar  3 19:34 /etc/resolv.conf -> /var/run/NetworkManager/resolv.conf
On my machine network-manager is managing resolved. So, I opted to handle my connections through network-manager. Yours might be different. If it says /etc/resolv.conf is a link to
Quote:
/var/run/systemd-resolved/stub-resolve.conf
, see if the service is running:

Code:
& systemctl status systemd-resolved
If it it's not enabled, enable it and then start it. Whatever the case, make sure /etc/resolv.conf links to the correct file, and that your connections are managed correctly.
 
Old 03-04-2018, 03:11 PM   #9
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
OP check your router and ensure that it is configured properly to give out the correct DNS Servers. No need to have systemd-resolved or anything else running if you are not providing DNS Services.
 
Old 03-04-2018, 03:51 PM   #10
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
resolved resolves DNS for clients also.
 
Old 03-05-2018, 04:00 AM   #11
abukapsoun
LQ Newbie
 
Registered: Mar 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
I replace virtualbox with VMware, and everything works fine now.. so something in the Virtualbox
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FC13 install can ping by hostname, ssh by hostname fails jeffk42 Linux - Networking 4 11-14-2011 11:27 AM
ping hostname ociugi Linux - Networking 3 02-08-2011 01:28 AM
BIND9 SLOW ping when ping by hostname dschuett Linux - Networking 10 02-02-2011 04:17 PM
can ping ip but not hostname mrbabis Linux - Networking 17 06-07-2006 12:26 PM
windows 98 m/c ping to ip address of red hat server but fails to ping hostname ravilohot Linux - Networking 2 09-07-2004 04:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration