【问题标题】:How to get current nameservers of o.s. from nodejs?如何获取操作系统的当前名称服务器来自nodejs?
【发布时间】:2021-10-15 09:58:06
【问题描述】:

使用 bash 从 bash 获取当前名称服务器:

$ cat /etc/resolv.conf

但是,如何从操作系统获取名称服务器。在跨平台中使用nodejs 10? (windows、mac、linux等)。

【问题讨论】:

标签: node.js nameservers


【解决方案1】:

这不是特定于 node.js,但以下命令可以。如果您执行该命令,则标准输出处理可以移动到节点中。

苹果机

scutil --dns | grep 'nameserver\[[0-9]*\]'

窗户

ipconfig /all | findstr /R "DNS\ Servers"

Linux 系统

systemd-resolve --status | grep "DNS Servers"

Linux 后备

grep ^nameserver /etc/resolv.conf

【讨论】:

    猜你喜欢
    • 2016-02-01
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 1970-01-01
    相关资源
    最近更新 更多