Network-related information on hosts required by network applications generally includes: hosts, networks, protocols, and services. In this information, the host and network information can be obtained either through the Domain Name System (DNS) or through related files, the service and protocol information is generally read from the corresponding file. System files related to network information are as follows:
| Information |
File Name |
Related functions |
| Host |
/Etc/hosts |
Gethostbyaddr, gethostbyname |
| Network |
/Etc/networks |
Getnetbyaddr, getnetbyname |
| Protocol |
/Etc/protocols |
Getprotobyname, getprotobynumber |
| Service |
/Etc/SER/vices |
Getservbyname, getservbyport |
Table
1:
Four files related to network informationWhen gethostbyname or gethostbyaddr is called in a program, the Linux system actually uses the/etc/hosts file to match the corresponding host name or IP address. The configuration format in the/etc/hosts file is as follows: IP address hostname alias
127.0.0.1 localhost local
192.168.1.202 linuxserver Server
............ ............ ......... The leftmost column is the Host IP information, and the middle column is the host name. All the columns that follow are aliases of the host.