Ubuntuで専用ネットワークインターフェイスを使用するゲートウェイ

Ubuntuで専用ネットワークインターフェイスを使用するゲートウェイ

Ubuntu 16.04 VMには、次のプライベートネットワークインターフェイスがあります。

# Private network
auto ens19
iface ens19 inet static
    address 10.10.10.179
    netmask 255.255.255.0
    mtu 1450

私のvLANが正しく機能するには、指定されたゲートウェイが必要なので、次のように接続しました。

# Private network
auto ens19
iface ens19 inet static
    address 10.10.10.179
    netmask 255.255.255.0
    mtu 1450
    gateway 10.10.10.1

ただし、そのゲートウェイを追加してnetworkingサービスを再起動するたびに、次のエラーで開始されません。

Dec 15 10:50:08 postfix0 ifup[1968]: RTNETLINK answers: File exists
Dec 15 10:50:08 postfix0 ifup[1968]: Failed to bring up ens19.

実行はip addr flush dev xxx役に立ちません。

それでは、この問題をどのように解決するのですか?

ベストアンサー1

名前付きルーティングテーブルを作成します。 pvtnetという名前は任意です。 DHCPが10.10.10ネットワークにアドレスを展開している場合、この操作は機能しません。

echo '200 pvtnet' >> /etc/iproute2/rt_tables

ファイルの修正、/etc/network/interfaces

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# DHCP hands out the DEFAULT gateway.
auto eth0 # use the real device name on your system
allow-hotplug eth0
iface eth0 inet dhcp

# The private network interface
auto ens19
allow-hotplug ens19
iface ens19 inet static
address 10.10.10.179
netmask 255.255.255.0
mtu 1450
post-up ip route add 10.10.10.0/24 dev ens19 src 10.10.10.179 table pvtnet
post-up ip route add default via 10.10.10.1 dev ens19 table pvtnet
post-up ip rule add from 10.10.10.179/32 table pvtnet
post-up ip rule add to 10.10.10.179/32 table pvtnet

おすすめ記事