如何為面向本地的介面設定別名

如何為面向本地的介面設定別名

我正在嘗試為面向本地網路的介面設定別名,但是當我嘗試啟動它時,我收到此錯誤:

RTNETLINK answers: File exists
Failed to bring up eth1:0.

這是我的 /etc/network/interfaces # Loopback device: auto lo iface lo inet Loopback

# device: eth0
auto  eth0
iface eth0 inet static
  address   X.X.X.X
  broadcast X.X.X.X
  netmask   255.255.255.0
  gateway   X.X.X.1

# device: eth1
auto  eth1
iface eth1 inet static
  address   10.0.0.1
  netmask   255.255.252.0

# device: eth1:0
auto  eth1:0
iface eth1:0 inet static
  address   10.0.0.2
  netmask   255.255.252.0

# default route to access subnet
up route add -net X.X.X.X netmask 255.255.255.0 gw X.X.X.1 eth0

答案1

「已經存在」的「文件」是預設路由(網關)。

ifup將會失敗,因為它將嘗試新增基本適配器已存在的預設路由。正如@DanatheSane 在評論中指出的那樣,您可以忽略這一點——別名仍然有效。

答案2

您確實應該刪除最後一行,因為嘗試執行與本eth0節中所做的完全相同的工作:

  • gateway設定意味著您將其作為(預設)網關。
  • netmask(with ) 新增本地網路的路由address,告訴您的機器如何發送可以在區域網路上到達的資料包。

總結:最後一行是多餘的。

相關內容