Link to home
Start Free TrialLog in
Avatar of Lucky Tham
Lucky Tham

asked on

Unable to Resolve Hostname on Redhat (Guest OS) on VirtualBox

Hi

My redhat (guest OS) having issue for not able to resolve the hostname like google.com but able to ping 8.8.8.8.

I didn't do anything at all just to ensure that it can ping Google first and my network subnet like 192.168.1.0/24 when my redhat added a NAT Network adapter without issue.

After that I connect my fortinet vpn client thr IPSec and still can ping and resolve my private cloud thr hostname.

Next day I do the same thing like connect to my iPad 4G network to my Hp laptop wifi.

Can ping and resolved on my hp laptop even being connected to vpn.

The guest os redhat from virtualbox on nat can ping 8.8.8.8 but not able to resolve now.

Why yesterday can and today can't without changing anything?

Thanks.
Avatar of Benjamin Van Ditmars
Benjamin Van Ditmars
Flag of Netherlands image

how is youre resolv configuration post youre /etc/resolv.
looks like an issue there.

on the host machine is windows firewall running ?
Post the following...

cat /etc/os-release
cat /etc/resolv.conf
netstat -plun | grep ":53 "

Open in new window

Avatar of Lucky Tham
Lucky Tham

ASKER

I've to configured the /etc/resolv.conf but keep having issue and the firewall is already disabled on my host.

Here is the output

User generated image
User generated image
Thanks.
Hi,

Not sure whether this info is useful or not. Thanks.

my laptop configuration.

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Fortinet virtual adapter
   Physical Address. . . . . . . . . : 00-09-0F-FE-00-01
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::3147:29ba:bc5c:2942%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.19.0.9(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, November 12, 2018 5:58:00 PM
   Lease Expires . . . . . . . . . . : Friday, December 20, 2154 12:30:24 AM
   Default Gateway . . . . . . . . . : 172.19.0.10
   DHCP Server . . . . . . . . . . . : 172.19.0.10
   DHCPv6 IAID . . . . . . . . . . . : 788531471
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-1E-13-43-10-E7-C6-EA-75-49
   DNS Servers . . . . . . . . . . . : 10.10.0.1
                                       0.0.0.0
   NetBIOS over Tcpip. . . . . . . . : Enabled

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265
   Physical Address. . . . . . . . . : 68-EC-C5-29-AF-3B
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::5b1:9850:9fcf:3550%31(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.20.10.9(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Lease Obtained. . . . . . . . . . : Monday, November 12, 2018 5:36:36 PM
   Lease Expires . . . . . . . . . . : Tuesday, November 13, 2018 5:22:12 PM
   Default Gateway . . . . . . . . . : 172.20.10.1
   DHCP Server . . . . . . . . . . . : 172.20.10.1
   DHCPv6 IAID . . . . . . . . . . . : 375975109
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-1E-13-43-10-E7-C6-EA-75-49
   DNS Servers . . . . . . . . . . . : 10.10.0.1
                                       172.20.10.1
   NetBIOS over Tcpip. . . . . . . . : Enabled


C:\Users\P1319181>route print
===========================================================================
Interface List
 27...00 ac f8 91 38 68 ......VPN Client Adapter - VPN
  2...10 e7 c6 ea 75 49 ......Realtek PCIe GBE Family Controller
  5...00 09 0f fe 00 01 ......Fortinet virtual adapter
 31...68 ec c5 29 af 3b ......Intel(R) Dual Band Wireless-AC 8265
 11...68 ec c5 29 af 3f ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
 13...00 00 00 00 00 00 00 e0 Microsoft Teredo Tunneling Adapter
 17...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #6
 15...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #7
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      172.20.10.1      172.20.10.9     90
          0.0.0.0          0.0.0.0      172.19.0.10       172.19.0.9     35
  118.201.183.142  255.255.255.255      172.20.10.1      172.20.10.9     55
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
       172.19.0.0    255.255.255.0         On-link        172.19.0.9    291
       172.19.0.9  255.255.255.255         On-link        172.19.0.9    291
     172.19.0.255  255.255.255.255         On-link        172.19.0.9    291
      172.20.10.0  255.255.255.240         On-link       172.20.10.9    311
      172.20.10.9  255.255.255.255         On-link       172.20.10.9    311
     172.20.10.15  255.255.255.255         On-link       172.20.10.9    311
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link       172.20.10.9    311
        224.0.0.0        240.0.0.0         On-link        172.19.0.9    291
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link       172.20.10.9    311
  255.255.255.255  255.255.255.255         On-link        172.19.0.9    291
===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
      160.102.0.0      255.255.0.0    160.101.0.254       1
      160.103.0.0      255.255.0.0    160.101.0.254       1
          0.0.0.0          0.0.0.0    192.168.1.254  Default
===========================================================================

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
 13    331 ::/0                     On-link
  1    331 ::1/128                  On-link
 13    331 2001::/32                On-link
 13    331 2001:0:9d38:6abd:8b3:11ad:8936:4871/128
                                    On-link
 31    311 fe80::/64                On-link
  5    291 fe80::/64                On-link
 13    331 fe80::/64                On-link
 31    311 fe80::5b1:9850:9fcf:3550/128
                                    On-link
 13    331 fe80::8b3:11ad:8936:4871/128
                                    On-link
  5    291 fe80::3147:29ba:bc5c:2942/128
                                    On-link
  1    331 ff00::/8                 On-link
 31    311 ff00::/8                 On-link
 13    331 ff00::/8                 On-link
  5    291 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

User generated image
Couple of things.

1) You must install netstat, before you can run netstat.

Having this data is essential to know if systemd-resolved is in play, as this poor excuse of code is the bane of all DNS lookups.

2) Your /etc/resolv.conf is empty, so just try adding the following to this file for now...

nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

Open in new window


3) To make your /etc/resolv.conf entries permanent, you'll likely have to add something to one of your /etc/resolve.d/* files or however CentOS 7 manages/generates /etc/resolv.conf at boot time.
Hi,

1. Can't yum install netstat as it can't resolve with error.

2.Tried vi /etc/resolv.conf and add in exactly the nameserver given but can't write over it and save as a root super user
#generated by network manager
search localdomain

nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

:wq!

/etc/network/interfaces" E212: Can't open file for writing
Press ENTER or type command to continue

3. How to do it?

Thanks
add nameserver entries in /etc/resolv.conf file

Check with network admin on dns servers ip addresses used in your network

e.g.

nameserver 8.8.8.8
nameserver 8.8.4.4

also, check for entry like below in /etc/nsswitch.conf file

hosts: files dns
what ls -l /etc/resolv.conf shows?
can do nslookup to find out dns like 192.168.1.254 on my host laptop?


hosts: files dns myhostname
your file owner is root and file perms allow you to write to it.

What you do for editing and storing changes?

what id command returns?

you can use same dns server used on laptop
What you do for editing and storing changes?

User generated image
what id command returns?

:wq
E505 "/etc/resolv.conf" is read only (add ! to override)

:wq!
User generated image
User generated image
RedHat uses yum and store network configuration in /etc/sysconfig/network-scripts
Debian uses apt (apt-get) and /etc/network/interfaces

mixing this setups will not work.

/etc/resolv.conf should be editable... unless selinux is used in enforcing mode.
 Which may verify well be the case.
In that case you may need to update the network manager config files.
I am not so good in Redhat so can advice how to verify and resolve it accordingly.

Thanks.
what does ls -Z /etc/resolv.conf show?
-Z means show security context for an object.
selinux prevents the root user to write /etc/resolv.conf.
you need to hold the system_u:object_r:net_conf_t:s0 security context to update it.

You should be able to update the system configuration (which includes this file) using nmtui or the network manager gui tooling.
How to do it?
run the nmtui program in a shell, and configure an interface, (static) and add the dns servers you need with that spec.
But Already a DHCP client. Why still need to add a static interface. Can just an dns / host record?
can't save again.

User generated image
Then you need to tell the DHCP server which dns servers should be used and those will endup in the /etc/resolv.conf
unless the disk is set to read/only due to errors during booting  the system.

Is this still an issue?

Just reading over this question again.

All the errors related to /etc/resolv.conf appear related to how you've done your login.

Looks like you're actual or effective ID != root.

You can check this by this command...

net15 # id
uid=0(root) gid=0(root) groups=0(root)

Open in new window


If you see anything different, then no comments above will help, till commands are executed as root.

This can be as simple as...

sudo vi /etc/resolv.conf

Open in new window


Or you can do this...

sudo bash

Open in new window


To start a root shell, so all your commands execute as root.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.