dns和dhcp服务和mariadb服务
1:dhcp服务
就是自动的获取地址,即可
路由器分配ip地址,安装了dhcp服务器,
目的:客户端自动的获取ip地址
操作:
#安装包名 [root@rhel9 /]# yum -y install dhcp-server [root@rhel9 /]# systemctl status dhcpd ○ dhcpd.service - DHCPv4 Server Daemon Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disa> Active: inactive (dead) Docs: man:dhcpd(8) man:dhcpd.conf(5) dhcp配置文件在这里 [root@rhel9 dhcp]# ls dhclient.d dhcpd6.conf dhcpd.conf [root@rhel9 dhcp]# pwd /etc/dhcp [root@rhel9 dhcp]# cat dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp-server/dhcpd.conf.example # see dhcpd.conf(5) man page # subnet 192.168.109.0 netmask 255.255.255.0 { range 192.168.109.77 192.168.109.89; ##dhcp地址段就在里面 option routers 192.168.109.2; ##默认的路由 option broadcast-address 192.168.109.255; ##广播地址 default-lease-time 7200; ##默认的租期 max-lease-time 24000; #最大的租期 }
客户端就只需要网卡自启,开启dhcp服务即可,就能获得dhcp自动分配的地址了
dhcp固定地址:
就是设置某些主机是固定的
###思路就是先绑定mac地址即可 subnet 192.168.109.0 netmask 255.255.255.0 { range 192.168.109.25 192.168.109.200; option routers 192.168.109.2; option broadcast-address 192.168.109.255; default-lease-time 1000; max-lease-time 3000; } host 339 { hardware ethernet 00:0c:29:f8:f4:11; fixed-address 192.168.109.88; }
客户端需要自动的获取地址
2:dns服务
正反解查询命令:host,nslookup,dig命令
1、host命令
#查询这个命令在哪里包 [root@rhel9 /]# host www.baidu.com www.baidu.com is an alias for www.a.shifen.com. www.a.shifen.com has address 183.2.172.185 www.a.shifen.com has address 183.2.172.42 www.a.shifen.com has IPv6 address 240e:ff:e020:966:0:ff:b042:f296 www.a.shifen.com has IPv6 address 240e:ff:e020:9ae:0:ff:b014:8e8b [root@rhel9 /]# host -a www.baidu.com Trying "www.baidu.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42023 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.baidu.com. IN ANY ;; ANSWER SECTION: www.baidu.com. 1173 IN CNAME www.a.shifen.com. Received 58 bytes from 119.29.29.29#53 in 21 ms
2、nslookup命令
[root@rhel9 /]# nslookup www.baidu.com Server: 119.29.29.29 Address: 119.29.29.29#53 #为119这个的53为端口 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 180.101.50.188 Name: www.a.shifen.com Address: 180.101.50.242 Name: www.a.shifen.com Address: 240e:ff:e020:966:0:ff:b042:f296 Name: www.a.shifen.com Address: 240e:ff:e020:9ae:0:ff:b014:8e8b #查看本机的dns服务ip地址 [root@rhel9 /]# nslookup server Server: 119.29.29.29 Address: 119.29.29.29#53 ** server can't find server: NXDOMAIN
3、dig命令
域名查询命令,
[root@rhel9 /]# dig www.baidu.com ; <<>> DiG 9.16.23-RH <<>> www.baidu.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4101 ##noerror本次检查没有问题 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ; COOKIE: 04d491e686ffa7f3 (echoed) ;; QUESTION SECTION: ;www.baidu.com. IN A ;; ANSWER SECTION: www.baidu.com. 1137 IN CNAME www.a.shifen.com. www.a.shifen.com. 237 IN A 180.101.50.242 www.a.shifen.com. 237 IN A 180.101.50.188 ;; Query time: 26 msec ;; SERVER: 119.29.29.29#53(119.29.29.29) ;; WHEN: Fri May 10 15:58:10 CST 2024 ;; MSG SIZE rcvd: 113
目的:将www.cs107.net这个域名解析为192.168.109.222这个地址
dns服务器操作:
[root@rhel9 /]# yum -y install bind #主配置文件修改 [root@rhel9 /]# vim /etc/named.conf listen-on port 53 { 127.0.0.1;any; }; allow-query { localhost;any; }; dnssec-validation no; 子配置文件的修改 [root@rhel9 /]# vim /etc/named.rfc1912.zones zone "cs107.net" IN{ ##解析这个域名 type master; file "eee.zone"; ##zone的文件为 allow-update { none; }; }; #zone的配置文件修改 直接复制模版文件 [root@rhel9 /]# cp /var/named/named.localhost /var/named/eee.zone [root@rhel9 /]# cat /var/named/eee.zone $TTL 1D @ IN SOA cs107.net. rname.invalid. ( ###这个就是域名 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ NS www.cs107.net. ###要解析的 www A 192.168.109.222 ###www.cs107.net 解析为 这个ip地址 #检查格式 [root@rhel9 /]# named-checkconf /etc/named.conf [root@rhel9 /]# named-checkconf /etc/named.rfc1912.zones 最后一个检查要进入里面去才行 [root@rhel9 named]# pwd /var/named [root@rhel9 named]# named-checkzone eee.zone eee.zone zone eee.zone/IN: loaded serial 0 OK #重启服务 [root@rhel9 named]# systemctl restart named
客户端的操作:
#指定域名解析服务器 [root@client ~]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 192.168.109.10
注意的点就是zone文件的拥有人和组都是named用户才行,才能进行读取
防火墙和selinux的放行
[root@rhel9 named]# firewall-cmd --permanent --add-service=dns success [root@rhel9 named]# firewall-cmd --reload success [root@rhel9 named]# setsebool -P named_write_master_zones on
3:数据库服务
yum -y install mariadb-server systemctl restart mariadb systemctl enable mariadb mysql_secure_installation mysql -uroot -predhat