LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I can ping IP but not hostname (https://www.linuxquestions.org/questions/linux-newbie-8/i-can-ping-ip-but-not-hostname-4175624845/)

abukapsoun 03-03-2018 05:57 AM

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,

trognet 03-03-2018 06:09 AM

/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.

abukapsoun 03-03-2018 06:19 AM

Hi
I have tried adding 8.8.8.8 and 8.8.4.4 in the resolv.conf but it didnt work either

jlinkels 03-03-2018 06:22 AM

Duplicate reply

jlinkels 03-03-2018 06:23 AM

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

BW-userx 03-03-2018 08:59 AM

never mind it is a broader spectrum then I thought.

abukapsoun 03-03-2018 09:36 AM

I cannot run dig, it is not installed. And since no name resolution i cannot run yum either

Quote:

Originally Posted by jlinkels (Post 5826706)
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


AwesomeMachine 03-03-2018 10:19 PM

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.

lazydog 03-04-2018 04:11 PM

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.

AwesomeMachine 03-04-2018 04:51 PM

resolved resolves DNS for clients also.

abukapsoun 03-05-2018 05:00 AM

I replace virtualbox with VMware, and everything works fine now.. so something in the Virtualbox


All times are GMT -5. The time now is 08:47 PM.