簡體   English   中英

netplan static 和動態接口沒有 static 的默認路由?

[英]netplan static and dynamic interfaces without default route for static?

我正在嘗試在 ubuntu 服務器上使用 netplan 配置 static 和動態地址。 問題是,雖然 static 接口使用度量 100 獲取路由,但它仍然會創建度量為 0 的默認路由 (0.0.0.0),這與我的動態接口發生沖突並且我失去了與 Internet 的連接。

有沒有辦法告訴 netplan 停止向路由添加度量為 0(或任何度量)的默認路由(0.0.0.0)?

這是我的配置:

network:
  ethernets:
    enp0s3:
      dhcp4: true
      dhcp4-overrides:
        route-metric: 0

    enp0s8:
       dhcp4: false
       dhcp4-overrides:
           use-routes: false
       addresses: [192.168.200.1/24]
       gateway4: 192.168.200.1
       nameservers:
           addresses: [8.8.8.8]
       routes:
       - to: 0.0.0.0/0
         via: 192.168.200.1
         metric: 100

  version: 2

刪除網關線路對我有用:

network:
  ethernets:
    enp0s3:
      dhcp4: true
      dhcp4-overrides:
        route-metric: 0

    enp0s8:
       dhcp4: false
       dhcp4-overrides:
           use-routes: false
       addresses: [192.168.200.1/24]
       # ------------ COMMENT THIS LINE ---------- gateway4: 192.168.200.1
       nameservers:
           addresses: [8.8.8.8]
       routes:
       - to: 0.0.0.0/0
         via: 192.168.200.1
         metric: 100

  version: 2

基於這個答案- 刪除以下行也可以:

       dhcp4-overrides:
         use-routes: false
       gateway4: 192.168.200.1

無需指定dhcp4-overrides ,因為這是一條 static 路由。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM