特定のインターフェイスでのみ dhcpcd を明示的に起動します。

特定のインターフェイスでのみ dhcpcd を明示的に起動します。

私のコンピュータには複数のインターフェイスがあり、通常はDHCPサーバーが実行されています。今、さまざまな「設定」に異なる反応をしたいと思います。

  • Wi-Fiがある場合は、Wi-Fiを使用してください。
  • イーサネットがある場合は、イーサネットを使用してください(そこに追加の設定ファイルもあります)。
  • 両方がある場合は、どちらかを使用してください(または両方または他のもの...ただ動作します)。
  • インターフェイスusb0または問題が発生したときにusb1誰かが質問を発行する場合にのみ、dhcpを有効にしてください。dhcpcd <interface>

私の現在の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

徹底的にテストしていませんが、Wi-Fi/イーサネット部分は機能しているようです。しかし、USBインターフェイスがDHCPコマンドにのみ応答するように設定する方法はわかりません。nogatewayUSBポートがATM基本ルーティングを壊すのを防ぐためです。

どのように設定する必要がありますかdhcpcd

編集1: Gentooシステムを使用していますが、私のネットワーク以外にはもうネットワーク構成はありません。wpa_supplicant.conf

ベストアンサー1

使用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).

[-Z, --denyinterfaces pattern]IMOが本番環境では理想的ではありませんが、dhcpcdの引数である、を使用することも可能です[-z, --allowinterfaces pattern]

おすすめ記事