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

Lucky Tham
Lucky Tham used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

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

on the host machine is windows firewall running ?
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Post the following...

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

Open in new window

Lucky ThamFreelancer

Author

Commented:
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

redhat_1.jpg
redhat_2.jpg
Thanks.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Lucky ThamFreelancer

Author

Commented:
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

redhat_gw1.jpg
David FavorFractional CTO
Distinguished Expert 2018

Commented:
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.
Lucky ThamFreelancer

Author

Commented:
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
Top Expert 2007

Commented:
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
Top Expert 2007

Commented:
what ls -l /etc/resolv.conf shows?
Lucky ThamFreelancer

Author

Commented:
redhat_3.jpg
Lucky ThamFreelancer

Author

Commented:
can do nslookup to find out dns like 192.168.1.254 on my host laptop?


hosts: files dns myhostname
Top Expert 2007

Commented:
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
Lucky ThamFreelancer

Author

Commented:
What you do for editing and storing changes?

redhat_5_DNS.jpg
what id command returns?

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

:wq!
redhat_6_E212.jpg
redhat_4_Error.jpg
nociSoftware Engineer
Distinguished Expert 2018

Commented:
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.
Lucky ThamFreelancer

Author

Commented:
I am not so good in Redhat so can advice how to verify and resolve it accordingly.

Thanks.
nociSoftware Engineer
Distinguished Expert 2018

Commented:
what does ls -Z /etc/resolv.conf show?
-Z means show security context for an object.
Lucky ThamFreelancer

Author

Commented:
redhat_9_sec.jpg
nociSoftware Engineer
Distinguished Expert 2018

Commented:
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.
Lucky ThamFreelancer

Author

Commented:
How to do it?
nociSoftware Engineer
Distinguished Expert 2018

Commented:
run the nmtui program in a shell, and configure an interface, (static) and add the dns servers you need with that spec.
Lucky ThamFreelancer

Author

Commented:
But Already a DHCP client. Why still need to add a static interface. Can just an dns / host record?
Lucky ThamFreelancer

Author

Commented:
can't save again.

redhat_10_sec.jpg
nociSoftware Engineer
Distinguished Expert 2018

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial