User-friendly domain names (example.com) have made the internet easier to use. Without them, we would have to find servers by IP address (e.g. 1.2.3.4).
The mapping of domains to IP addresses is achieved using Domain Name System (DNS). Although most PHP functions that need to look up domain names can use their PHP host’s DNS configuration automatically, other functions require a special file called /etc/resolv.conf
. Resolv.conf is required in these scenarios:
- When you use advanced PHP DNS functions such as
dns_get_record
andcheckdnsrr
. - When PHP needs to look up special records, such as mail exchange (MX) or service (SRV) records. For example, the MongoDB driver uses SRV records to find MongoDB port numbers.
- When doing nslookup from QSH and other Unix-like environments.
Creating the configuration file
Create the /etc/resolv.conf
file using the following IBM i command:
QSH CMD('touch -C 819 /etc/resolv.conf')
The “-C 819” specifies ASCII encoding.
Next, using your favorite IFS file editor, or
EDTF '/etc/resolv.conf'
(in which case, choose stream file EOL option *LF on the EDTF options screen),
add a nameserver
line for each DNS server you wish to use. To find out which name servers your IBM i uses, prompt (F4) on the IBM i CHGTCPDMN
command. An example configuration, using Google nameservers:
nameserver 8.8.8.8 nameserver 8.8.4.4
For more information on configuring /etc/resolv.conf
on IBM i PASE, refer to the AIX documentation for resolver.conf.