In Linux, you must first find the configuration file to configure the static IP address, DNS, and host name. This is a required way to work in Linux. The configuration follows the example step by step. I believe that you will eventually complete configuring static IP addresses and DNS and host names in Linux.
The configuration file is located:
/Etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = static
IPADDR = 192.168.0.3
NETMASK = 255.255.255.0
GATEWAY = 192.168.0.1
Make the IP address take effect:
/Sbin/ifdown eth0
/Sbin/ifup eth0
Configure dns resolution
Echo "nameserver 211.98.1.28">/etc/resolv. conf
Notify gateway to update information:
/Etc/init. d/network restart
① Introduction
DNS is the Domain Name System, which can convert a Domain Name such as www.21php.com to an IP address such as 211.152.50.35. If there is no DNS, When you browse the website 21php.com, you must use numbers that are so hard to remember as 211.152.50.35. The DNS server provides the DNS service. There are three types of DNS servers: Cache-only server, Primary Name server, and Second Name Server ).
The detailed principles, workflows, terms, and concepts of DNS are limited by space. Can read special articles such as DNS-HOWTO to learn.
② Configure the primary DNS Server
First, let's make the following assumptions: server A is the primary Domain Name Server of 21php.com, its IP address is 11.0.0.1, server B is the secondary Domain Name Server of 21php.com, and its IP address is 11.0.0.2;
Next we configure the primary DNS server 11.0.0.1 as 21PHP. COM.
The dns function in Linux is implemented through the bind software. After the bind software is installed, several inherent files are generated, which can be divided into two categories: configuration files under the/etc directory and dns record files under the/var/named directory. Add other related files to set up the dns server. The following is a list and description of all files related to dns settings.
Hosts, host. conf, resolv. conf, named. boot, and named. conf are located in the/etc directory.
1. In the "hosts" file, the host name and IP address are defined, and the IP address and Host Name of the computer that will run dns are also defined. Content:
127.0.0.1 localhost. localdomain localhost
2. "host. conf file [Boban Note: originally written as hosts. conf], "order hosts bind" Statement, specifying the resolution order for the host name is first found in hosts, and then found in the dns server record. "Multi on" allows a host name to correspond to multiple IP addresses. Content:
Order hosts, bind
Multi on
Nospoof on
3. In the "resolv. conf" file, "nameserver 10.0.0.211" specifies the address of the dns server. Note: This file is essential for computers that do not use dns servers (non-windows systems; Windows systems set this file in "Network Properties. If you have not set the local machine as a dns server, you must specify the address of a dns server to resolve the domain name. You can write up to three addresses as the candidate dns server for the previous failure. "Domain zrs.com" specifies the default domain. File Content:
Domain 21php.com
Nameserver 11.0.0.1
4. The "named. boot" file is the configuration file used by the bind software of earlier versions. Now the new version has already been stored in "named. conf ". Named. conf is the core file of dns server configuration. The following is a piece of explanation.
# Named. conf-configuration for bind
#
# Generated automatically by bindconf, alchemist et al.
Controls {
Inet 127.0.0.1 allow {localhost;} keys {rndckey ;};
};
Include "/etc/rndc. key"; options {
Directory "/var/named /";
};
Zone "."{
Type hint;
File "named. ca ";
};
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Zone "localhost "{
Type master;
File "localhost. zone ";
};
Zone "21php.com "{
Type master;
Optional Y yes;
File "21php.com ";
};
In the above Article, # Is the annotation symbol. The meanings of other lines are as follows:
Diretables/var/named
Specify that named reads DNS data files from the/var/named directory. You can specify and create this directory. All DNS data files are stored in this directory;
Zone "."{
Type hint;
File "named. ca ";
};
Specify named to obtain the top-level "root" server address of the Internet from the named. ca file.
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Specify the named as the IP address range of 127.0.0 to the master server, named. the local file contains 127.0.0. * form of address-to-Domain Name conversion data (127.0.0 segment address is the internal loopback address of the LAN interface );
Zone "localhost "{
Type master;
File "localhost. zone ";
};
The DNS file data containing localhost is stored in/var/named/localhost. zone;
Zone "21php.com "{
Type master;
Optional Y yes;
File "21php.com. zone ";
};
The preceding statement indicates that DNS data in the domain 21php.com is stored in 21php.com. zone in the/var/named/directory;
You can use the text editor to open/var/named/21php.com. zone. The content is as follows:
$ TTL 86400 @ in soa @ root. localhost (
2; serial
28800; refresh
7200; retry
604800; expire
86400; ttl
)
@ In ns localhost
Www in a 11.0.0.233
Www2 in a 11.0.0.23
Forum in a 11.0.0.10
@ In mx 5 mail.21php.com.
The first part of the file is the corresponding parameter settings, this part does not need to be modified, and the subsequent part is the specific DNS data;
For example:
Www in a 11.0.0.233
Resolve www.21php.com to 11.0.0.233;
Www2 in a 11.0.0.23
Resolve www2.21php.com to 11.0.0.23;
Club in a 11.0.0.10
Resolve club.21php.com to 11.0.0.10;
Next, I will introduce how to configure static IP addresses and DNS and host names in Linux.
- Linux compression command 1) tar
- Detailed modification of Linux system firewall
- Summary all Linux compression and decompression commands
- Roles of seven Linux Command destruction
- How to Use the Linux rescue mode