跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 求助:启动器从 openrc 切换到 systemd,因 systemd-networkd 配置网络,导致 dnsmasq 启动失败!
未分類
8 3 月 2021

求助:启动器从 openrc 切换到 systemd,因 systemd-networkd 配置网络,导致 dnsmasq 启动失败!

求助:启动器从 openrc 切换到 systemd,因 systemd-networkd 配置网络,导致 dnsmasq 启动失败!

資深大佬 : xivisi 0

如标题所述,自启动 dnsmasq 会失败,进入系统后手动启动 dnsmasq 服务则一切正常。 根据错误提示:

3 月 08 20:24:56 LINUX systemd[1]: Starting A lightweight DHCP and caching DNS server…

3 月 08 20:24:56 LINUX dnsmasq[228]: dnsmasq: syntax check OK.

3 月 08 20:24:56 LINUX systemd[1]: Started A lightweight DHCP and caching DNS server.

3 月 08 20:24:56 LINUX dnsmasq[232]: dnsmasq: failed to create listening socket for 10.0.1.1: 无法指定被请求的地址

3 月 08 20:24:56 LINUX systemd[1]: dnsmasq.service: Main process exited, code=exited,,status=2/INVALIDARGUMENT

3 月 08 20:24:56 LINUX systemd[1]: dnsmasq.service: Failed with result ‘exit-code’.

可知,是无法绑定我设置的局域网本机地址:10.0.1.1, 该地址是我用 systemd-networkd 配置的静态地址。根据系统启动后再次运行该服务又一切正常,初步判断是因为 dnsmasq 启动时,网络还没有配置好。

但是服务的依赖配置,感觉又没什么问题,不知道怎么解决了? 难道写个 sh 脚本,特意等待若干秒,再启动 dnsmasq ??

[Unit]

Description=A lightweight DHCP and caching DNS server

After=network.target

[Service]

Type=simple

ExecStartPre=/usr/sbin/dnsmasq –test

ExecStart=/usr/sbin/dnsmasq -k

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

大佬有話說 (8)

  • 資深大佬 : codehz

    试试
    After=network-online.target
    Wants=network-online.target

  • 資深大佬 : jim9606

    试下改成这个
    After=systemd-networkd.service
    Before=network.target
    参考自 systemd-resolved.setvice

  • 資深大佬 : Jirajine

    systemd 非常的激进,你不显示指定 After 的全都会并行启动。

    https://wiki.archlinux.org/index.php/Systemd#Handling_dependencies

    With systemd, dependencies can be resolved by designing the unit files correctly. The most typical case is that the unit A requires the unit B to be running before A is started. In that case add Requires=B and After=B to the [Unit] section of A. If the dependency is optional, add Wants=B and After=B instead. Note that Wants= and Requires= do not imply After=, meaning that if After= is not specified, the two units will be started in parallel.

  • 主 資深大佬 : xivisi

    @codehz 会导致一直等待服务中,没有真正运行程序。

  • 主 資深大佬 : xivisi

    @jim9606 现象一样……

  • 資深大佬 : defunct9

    开 ssh,让我上去看看

  • 資深大佬 : tinkerer

    要暴力一点直接把 Restart=always 加进去

  • 主 資深大佬 : xivisi

    @tinkerer 暂时这样暴力解决……

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具