RedHat系Linuxで新規に追加したネットワークカード(NIC)へのIPアドレス設定方法です。
ネットワークデバイス名の確認
まず、追加したNICのネットワークデバイス名を確認します。下記のコマンドを実行
nmcli device
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-1.png)
eth1が追加されています。
イーサネットコネクションの追加
まず、NICを追加します。
nmcli connection add type ethernet ifname (デバイス名) con-name (コネクション名)
今回は
nmcli connection add type ethernet ifname eth1 con-name eth1
と入力します。
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-2.png)
nmcli deviceでコネクションが追加されたのが分かります。
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-3.png)
IPアドレスの設定
IPアドレスの設定
IPアドレスを手動で設定します。下記の設定をします。
nmcli connection modify (コネクション名) ipv4.method manual(手動設定の場合) ipv4.addresses (IPアドレス/マスクビット数)
IPアドレス 10.0.0.253
サブネットマスク 255.0.0.0 (8ビットマスク)
デフォルトゲートウェイ 10.0.0.254
nmcli connection modify eth1 ipv4.method manual ipv4.addresses 10.0.0.253/8
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-4-1024x33.png)
ゲートウェイの設定
nmcli connection modify (コネクション名) ipv4.gateway (ゲートウェイのIPアドレス)
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-5.png)
コネクションを有効化
コネクションを有効化します。
nmcli connection up (コネクション名)
nmcli connection up eth1
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-6-1024x50.png)
ネットワークが設定されました。
![](https://windows-podcast.com/sundayprogrammer/wp-content/uploads/2022/11/image-7-1024x950.png)