首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅在特定接口上启动dhcpcd。

仅在特定接口上启动dhcpcd。
EN

Unix & Linux用户
提问于 2016-12-11 23:05:57
回答 1查看 4.6K关注 0票数 0

在我的机器上,我有多个接口,经常有一个dhcp服务器在运行。我现在想对不同的“设置”做出不同的反应:

  • 当有wifi时,使用wifi。
  • 当有以太网时,使用以太网(我在那里也有一个额外的配置文件)
  • 当两者兼而有之时,使用其中一种(或两者兼而有之)。只是工作)
  • 当接口usb0usb1发生时,只有在某人发出dhcpcd <interface>时才启用dhcp。

我现在的dhcpcd.conf看起来就像

代码语言:javascript
复制
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private


interface eth0
arping 192.168.1.77

profile 192.168.1.77
static ip_address=192.168.1.65
static routers=192.168.1.77
static domain_name_servers=192.168.1.77


interface usb0
nogateway

interface usb1
nogateway

虽然我还没有对它进行彻底的测试,但是wifi/以太网部分似乎工作正常。但我不知道,如何设置我的usb接口,以只响应DHCP命令。nogateway只是为了防止usb接口破坏我的默认路径ATM。

如何配置dhcpcd

编辑1:我在一个Gentoo系统上,除了我的wpa_supplicant.conf之外,没有其他的网络配置

EN

回答 1

Unix & Linux用户

发布于 2020-04-20 16:39:09

考虑在allowinterfaces和/或denyinterfaces设置中使用/etc/dhcpcd.conf。来自man dhcpcd.conf

代码语言:javascript
复制
 allowinterfaces pattern
         When discovering interfaces, the interface name must match
         pattern which is a space or comma separated list of patterns
         passed to fnmatch(3).  If the same interface is matched in
         denyinterfaces then it is still denied.

 denyinterfaces pattern
         When discovering interfaces, the interface name must not match
         pattern which is a space or comma separated list of patterns
         passed to fnmatch(3).

也有可能,虽然IMO在生产中不那么理想,但使用args到dhcpcd、[-Z, --denyinterfaces pattern][-z, --allowinterfaces pattern]

票数 4
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/329690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档