/etc/dhcpcd.conf で静的値を設定します。

/etc/dhcpcd.conf で静的値を設定します。

/etc/dhcpcd.confファイルの静的オプションに有効な値は何ですか(そしてどの用途に使用されますか?)

ファイルを編集してRaspberry(raspbianstretchを実行)のネットワークインターフェースを設定しています/etc/dhcpcd.conf
正しく設定できましたが、このファイルで利用可能なすべての構成オプション、特に静的構成が気になります。

dhcpcd.confのマニュアルページを読みましたが、静的オプションで許可されている値の説明が見つかりませんでした。 Googleでも何も見つかりません。

これdhcpcd.confのマニュアルページこう言ってみてください。

 static value
         Configures a static value.  If you set ip_address then dhcpcd
         will not attempt to obtain a lease and will just use the value
         for the address with an infinite lease time.  If you set
         ip6_address, dhcpcd will continue auto-configuation as normal.

         Here is an example which configures two static address,
         overriding the default IPv4 broadcast address, an IPv4 router,
         DNS and disables IPv6 auto-configuration.  You could also use the
         inform6 command here if you wished to obtain more information via
         DHCPv6.  For IPv4, you should use the inform ipaddress option
         instead of setting a static address.
               interface eth0
               noipv6rs
               static ip_address=192.168.0.10/24
               static broadcast_address=192.168.0.63
               static ip6_address=fd51:42f8:caae:d92e::ff/64
               static routers=192.168.0.1
               static domain_name_servers=192.168.0.1
               fd51:42f8:caae:d92e::1

         Here is an example for PPP which gives the destination a default
         route.  It uses the special destination keyword to insert the
         destination address into the value.
               interface ppp0
               static ip_address=
               destination routers

いくつかのチュートリアルを読んだ後、私が知っているすべての有効なオプションは次のとおりです。

  • IPアドレス

  • ルーター

  • ドメインネームサーバー

  • ドメイン名の検索

  • ドメイン名


JFYIの/etc/dhcpcd.conf構成ファイルは次のとおりです。

# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# 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
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

# Static IP configuration for eth0.
interface eth0
    static ip_address=192.168.12.234/24
    static routers=192.168.12.1
    static domain_name_servers=192.168.12.1
    nogateway

ベストアンサー1

私も同じ質問を受けましたが、明確な答えが見つからず、もう少し深い調査を始めました。

これが完全なリストかどうかはわかりませんが、staticソースコード(利用可能な場合)を表示して収集できるオプションの有効な値のリストは次のとおりです。ここ):

ip_address
subnet_mask
broadcast_address
routes
static_routes
classless_static_routes
ms_classless_static_routes
routers
interface_mtu
mtu
ip6_address

これらのパラメータはif-options.cファイルで直接処理されます。

ここが完全なのか確信できない部分であり、何が起こっているのか少し推測している部分です。ご存知のように、これには背中はdomain_name_servers含まれません。設定ファイルを解析し、上記のパラメータのいずれかを直接処理した後でも、未処理の一部のパラメータがまだ存在する可能性がありますif-options.c。これらの残りのパラメータは、デフォルトのフックスクリプト、特に20-resolv.confフックスクリプト(/usr/lib/dhcpcd/dhcpcd-hooks)で処理されると考えられています。これには次のオプションしかないと思います。

domain_name
domain_name_servers
domain_search

私が言ったように、私はソースコードを見るのに多くの時間を費やしたくないので、この最後のことについて少し自信がありません。したがって、どんな修正でも大歓迎です。

おすすめ記事