各状態(DOWN、NO CARRIER)でインターフェイスにIPを割り当てる

各状態(DOWN、NO CARRIER)でインターフェイスにIPを割り当てる

ホストのプライマリIPアドレスに依存するサービスがあり、そのアドレスがホストに設定されていない場合、サービスは開始されません。systemd-networkdそのインターフェイスへのリンクがハングしても静的に設定されたインターフェイスを操作し、特定の時間にリンクが失われてもその状態を維持する方法はありますか?

私はnetplanプレゼントを見つけましたignore-carrier: true。私も同じことが必要です。systemd-networkd

ベストアンサー1

systemd.networkのマニュアルを読みながら、次の2つのパラメータが見つかりました。

ConfigureWithoutCarrier=
           Takes a boolean. Allows networkd to configure a specific link even if it has no carrier. Defaults to false. If IgnoreCarrierLoss= is not explicitly set, it will default to this value.
 ActivationPolicy=
           Specifies the policy for systemd-networkd managing the link administrative state. Specifically, this controls how systemd-networkd changes the network device's "IFF_UP" flag, which is sometimes controlled by system administrators by running e.g., ip
           link set dev eth0 up or ip link set dev eth0 down, and can also be changed with networkctl up eth0 or networkctl down eth0.

           Takes one of "up", "always-up", "manual", "always-down", "down", or "bound". When "manual", systemd-networkd will not change the link's admin state automatically; the system administrator must bring the interface up or down manually, as desired. When
           "up" (the default) or "always-up", or "down" or "always-down", systemd-networkd will set the link up or down, respectively, when the interface is (re)configured. When "always-up" or "always-down", systemd-networkd will set the link up or down,
           respectively, any time systemd-networkd detects a change in the administrative state. When BindCarrier= is also set, this is automatically set to "bound" and any other value is ignored.

           When the policy is set to "down" or "manual", the default value of RequiredForOnline= is "no". When the policy is set to "always-down", the value of RequiredForOnline= forced to "no".

           The administrative state is not the same as the carrier state, so using "always-up" does not mean the link will never lose carrier. The link carrier depends on both the administrative state as well as the network device's physical connection. However,
           to avoid reconfiguration failures, when using "always-up", IgnoreCarrierLoss= is forced to true.

設定ConfigureWithoutCarrier=trueしてActivationPolicy=always-up成功しました

おすすめ記事