systemctl 相关功能

开启dns-server的时候一定要注意,默认的linux的systemd-resolved.service就是dns服务,会启动53端口。此时和dns-server因为需要dns解析,也是要启动53端口相冲突。因此这里,需要关闭linux的systemd-resolved.service服务。
命令如下:
systemctl stop systemd-resolved.service
systemctl disable systemd-resolved.service
同时需要设置默认的dns解析服务器
vi /etc/resolv.conf 配置
nameserver 8.8.8.8

1. 同时注意,执行systemctl status systemd-resolved.service后可以得到如下结果:

● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-04-11 14:13:36 UTC; 6 days ago
       Docs: man:systemd-resolved.service(8)
             https://www.freedesktop.org/wiki/Software/systemd/resolved
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 548 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9440)
     Memory: 8.7M
     CGroup: /system.slice/systemd-resolved.service
             └─548 /lib/systemd/systemd-resolved

Warning: some journal files were not opened due to insufficient permissions.

其中,loaded (/lib/systemd/system/systemd-resolved.service

就可以看出来是在这里配置的systemd-resolved.service启动参数,

2. vi后可以看到Restart=always,怪不得每次kill了后会自动重启。应为这里配置的是always。

3. 在使用root用户后,使用 journalctl -u systemd-resolved.service可以得到有关启动这个dns服务更详细的启动日志

你可能感兴趣的:(linux,服务器,运维)