Problems getting out of z/OS to the outside world, unknown host

I was in OMVS trying to install some software, but it could not find and use the IP address of the server. My current /etc/hosts file is here.

What’s the problem?

I issued

ping pypi.org      

and got

EZZ3111I Unknown host 'pypi.org'                     

There are two solutions

Capture an (IP address) resolver trace

I issued the command

export RESOLVER_TRACE=~/trace 

and reran the command.
This gave

 Resolver Trace Initialization Complete -> 2025/11/26 10:53:47.591994 

res_init Resolver values:
Setup file warning messages = No
CTRACE TRACERES option = No
Global Tcp/Ip Dataset = ADCD.Z31B.TCPPARMS(GBLTDATA)
Default Tcp/Ip Dataset = ADCD.Z31B.TCPPARMS(GBLTDATA)
Local Tcp/Ip Dataset = /etc/resolv.conf
Translation Table = TCPIP.STANDARD.TCPXLBIN
UserId/JobName = COLIN
...
res_init Succeeded
res_init Started: 2025/11/26 10:53:47.650509
res_init Ended: 2025/11/26 10:53:47.650537
***************************************************************************
GetAddrInfo Started: 2025/11/26 10:53:47.650677
GetAddrinfo Invoked with following inputs:
Host Name: pypi.org
No Service operand specified
Hints parameter supplied with settings:
ai_family = 0, ai_flags = 0x00000062
ai_protocol = 0, ai_socktype = 0
No NameServers specified, no DNS activity
GetAddrInfo Opening Socket for IOCTLs
BPX1SOC: RetVal = 0, RC = 0, Reason = 0x00000000, Type=IPv4
BPX1IOC: RetVal = 0, RC = 0, Reason = 0x00000000
GetAddrInfo Opened Socket 0x00000004
GetAddrInfo Only IPv4 Interfaces Exist
GetAddrInfo Searching Local Tables for IPv4 Address
Global IpNodes Dataset = ADCD.Z31B.TCPPARMS(ZPDTIPN1)
Default IpNodes Dataset = ADCD.Z31B.TCPPARMS(ZPDTIPN1)
Search order = CommonSearch
SITETABLE from globalipnodes ADCD.Z31B.TCPPARMS(ZPDTIPN1)
- Lookup for pypi.org
GetAddrInfo Closing IOCTL Socket 0x00000004
BPX1CLO: RetVal = 0, RC = 0, Reason = 0x00000000
GetAddrInfo Failed: RetVal = -1, RC = 1, Reason = 0x78AE1004
GetAddrInfo Ended: 2025/11/26 10:53:47.664992

Where 0x78AE1004 is The GETADDRINFO call failed because the host name cannot be found in DNS, or in the z/OS host configuration files (/etc/hosts or hlq.HOSTS.ADDRINFO).

I think this message is not very helpful. It was not found in sitetable

Default IpNodes Dataset = ADCD.Z31B.TCPPARMS(ZPDTIPN1) 

Use a Dynamic Name Server

You can tell TCPIP to go to a Name Server to look up the address in the internet.

The JCL for my RESOLVER started task has

//* 
//* TCPIP RESOLVER - COLINS
//*
//RESOLVER PROC PARMS=CTRACE(CTIRES00)
//*
//EZBREINI EXEC PGM=EZBREINI,REGION=0M,TIME=1440,
// PARM=('&PARMS',
// 'ENVAR("RESOLVER_TRACE=/var/log/resolver"/')
//SETUP DD DISP=SHR,DSN=COLIN.TCPPARMS(GBLRESOL),FREE=CLOSE
//SYSTCPT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//*

The //SETUP member GBLRESOL has

  DEFAULTTCPIPDATA('COLIN.TCPPARMS(GBLTDATA)') 
GLOBALTCPIPDATA(/etc/resolv.conf)
;
...

File /etc/resolv.conf has

nameserver 8.8.8.8 
nameserver 1.1.1.1

I enabled a resolver trace and pinged a new website.

The trace includes

**************************************************************************
GetAddrInfo Started: 2025/12/16 17:00:54.153989
GetAddrinfo Invoked with following inputs:
Host Name: hmrc.co.uk
...
res_search(hmrc.co.uk, C_IN, T_A)
res_search Host Alias Search found no alias
res_querydomain(hmrc.co.uk., , C_IN, T_A)
res_querydomain resolving name: hmrc.co.uk.
res_query(hmrc.co.uk., C_IN, T_A)
Querying resolver cache for hmrc.co.uk.
EZBRECFR: RetVal = 0, RC = 0, Reason = 0x00000000
No cache information was available
...
* * * * * Beginning of Message * * * * *
...
Number of Question RRs: 1
Question 1:
hmrc.co.uk
...
* * * * * End of Message * * * * *
res_send Name Server Capabilities
Monitoring intervals used = 5
Name server 8.8.8.8
...
Name server 1.1.1.1
...
res_send Sending query to Name Server 8.8.8.8
...
res_send received data via UDP. Message received:
* * * * * Beginning of Message * * * * *
...
Question 1:
hmrc.co.uk
...
Number of Answer RRs: 1
Answer 1:
hmrc.co.uk
...
TTL: 3600 (0 days, 1 hours, 0 minutes, 0 seconds)
195.171.114.178
* * * * * End of Message * * * * *
...
Attempting to cache results for hmrc.co.uk.
EZBRECAR: RetVal = 0, RC = 0, Reason = 0x00000000
Cache information was saved

The TTL from the DNS server says

 TTL:  3600 (0 days, 1 hours, 0 minutes, 0 seconds) 

When there was another request to the site within this time, the trace had

GetAddrInfo Started: 2025/12/16 17:01:09.426161 
GetAddrinfo Invoked with following inputs:
Host Name: hmrc.co.uk
...
Querying resolver cache for hmrc.co.uk.
EZBRECFR: RetVal = 0, RC = 0, Reason = 0x00000000
Cache data from 8.8.8.8 was retrieved
...
GetAddrInfo Succeeded: IP Address(es) found:
IP Address(1) is 195.171.114.178

showing the value from the DNS was retrieved from the local cache.

Explicitly specify the name to IP address mapping

If you do not want to use the DNS you can specify your own name to IP address mapping.

I reconfigured my RESOLVER started task to have

Global IpNodes Dataset  = /etc/hosts 
Default IpNodes Dataset = COLIN.TCPPARMS(ZPDTIPN1) 

and edited /etc/hosts to include

#IPAddress             Hostname   alias 
151.101.128.223        pypi.org    pip 

and the ping pypi.org worked

The trace file now had

 Global IpNodes Dataset  = /etc/hosts 
Default IpNodes Dataset = COLIN.TCPPARMS(ZPDTIPN1)
Search order = CommonSearch
SITETABLE from globalipnodes /etc/hosts
- Lookup for pypi.org
ADDRTABLE from globalipnodes /etc/hosts
- Lookup for 151.101.128.223
GetAddrInfo Returning Zero as Port Number
GetAddrInfo Built 1 Addrinfos
GetAddrInfo Closing IOCTL Socket 0x00000004
BPX1CLO: RetVal = 0, RC = 0, Reason = 0x00000000
GetAddrInfo Succeeded: IP Address(es) found:

When I changed this file to have multiple examples for the pypi.org

#IPAddress             Hostname   alias 
151.101.128.223 pypi.org pip
151.101.192.223 pypi.org pip

the trace file had

GetAddrinfo Invoked with following inputs: 
Host Name: pypi.org
...
SITETABLE from globalipnodes /etc/hosts
- Lookup for pypi.org
ADDRTABLE from globalipnodes /etc/hosts
- Lookup for 151.101.128.223
GetAddrInfo Returning Zero as Port Number
GetAddrInfo Built 2 Addrinfos
GetAddrInfo Closing IOCTL Socket 0x00000004
BPX1CLO: RetVal = 0, RC = 0, Reason = 0x00000000
GetAddrInfo Succeeded: IP Address(es) found:
IP Address(1) is 151.101.128.223
IP Address(2) is 151.101.192.223

and it returned both of them to the caller

My current /etc/hosts

After doing some Pip work to install products, my /etc/hosts file is now

#IPAddress             Hostname   alias 
151.101.128.223        pypi.org    pip 
151.101.192.223        pypi.org    pip 
151.101.192.223        files.pythonhosted.org   pipfiles 
20.26.156.215          github.com 
151.101.128.81         bbc.co.uk 
151.101.1.91           curl.se 
185.199.110.133        raw.githubusercontent.com 
185.199.110.133        release-assets.githubusercontent.com 
169.63.188.167         downloads.pyaitoolkit.ibm.net 

I created this list by resolver_trace to find the hostnames which failed, then adding them to the file along with their addresses using nslookup name.