c - FreeBSD:了解/var/db/dhclient.leases.<interface_name> dhcp 租用文件

标签 c network-programming freebsd dhcp

FreeBSD: network interface address: dhcp or static

现在跟进问题:

我决定查看租赁文件:/var/db/dhclient.leases..它到底告诉了我什么?/var/db/dhclient.leases.em0 的存在意味着 em0 有 DHCP 地址吗?该文件似乎不会随着重新启动而消失。

最佳答案

您应该阅读 dhclient 的手册页。这将回答您的大部分问题。如果失败,您可以浏览 /usr/src/sbin/dhclient 中的源代码。

另一种可能是使用devd(8)。这是一个守护进程,可以在发生特定事件时执行脚本或程序。它可以例如请注意网络接口(interface)何时“启动”或“关闭”。从默认的 /etc/devd.conf (另请参见 devd.conf(5)):

# Try to start dhclient on Ethernet-like interfaces when the link comes
# up.  Only devices that are configured to support DHCP will actually
# run it.  No link down rule exists because dhclient automatically exits
# when the link goes down.
#
notify 0 {
    match "system"          "IFNET";
    match "type"            "LINK_UP";
    media-type              "ethernet";
    action "/etc/rc.d/dhclient quietstart $subsystem";
};

关于c - FreeBSD:了解/var/db/dhclient.leases.<interface_name> dhcp 租用文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9522567/

相关文章:

从 Fortran 调用 C dll

c - unix select() 调用 : how to combine fd_sets?

Python多处理连接recv_bytes不返回数据

linux - 如何编辑 FreeBSD .gz 引导文件?

c - 为什么动态创建变量时会出现未声明的标识符错误?

c - 如何将文件中的 FILE 指针的位置保留在另一个文件指针中?

从不同大小的整数转换为指针?

c++ - c++ (Microsoft Visual Studio) 示例中的 TcpClient 类?

c - 什么时候需要 F_GETFL fcntl 命令的参数?

linux - 在 FreeBSD v8.1 上/proc/cpuinfo 是什么?