在我的机器上,我有多个接口,经常有一个dhcp服务器在运行。我现在想对不同的“设置”做出不同的反应:
usb0或usb1发生时,只有在某人发出dhcpcd <interface>时才启用dhcp。我现在的dhcpcd.conf看起来就像
# 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之外,没有其他的网络配置
发布于 2020-04-20 16:39:09
考虑在allowinterfaces和/或denyinterfaces设置中使用/etc/dhcpcd.conf。来自man dhcpcd.conf
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]。
https://unix.stackexchange.com/questions/329690
复制相似问题