linuxでNIC 2枚挿し以上の場合のデフォルトゲートウェイ

LinuxでNIC 2枚挿し以上の場合のデフォルトゲートウェイの設定

CentOS 7.6とCentOS 8.1で確認しています。

 

コマンドは、$ nmtui で設定します。

[X] Never use this network for default route

 

以下は参考例です。

Profile name: eno1

IPv4 CONFIGURATION: <Automatic>

DNS servers: 192.168.101.11

192.168.101.12

Search domain busyo.hogehoge.co.jp

hogehoge.co.jp

[ ] Never use this network for default route

[ ] Ignore automatically obtained routes

[X] Ignore automatically obtained DNS parameters

 

Profile name: eno2

IPv4 CONFIGURATION: <Automatic>

[X] Never use this network for default route

[ ] Ignore automatically obtained routes

[ ] Ignore automatically obtained DNS parameters

 

こうするとMetricの値が変わり優先順位が変わります。

※Metricの値が小さい方が優先されます。

# route

Kernel IP route table

Description       Gateway    Genmask           Flags Metric Ref Use Iface

default               gateway    0.0.0.0                 UG    100      0     0      eno1

140.10.242.0    0.0.0.0       255.255.255.0   UG    101      0     0      eno2

168.0.101.0      0.0.0.0       255.255.255.0   UG    100      0     0      eno1