忍者ブログ

◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例

   

【Linux】bonding設定

#=============================
# ■ bonding設定
#-----------------------------
# 作業前の設定状態の確認
ls -l /etc/sysconfig/network-scripts/
nmcli c
nmcli d
#-----------------------------
# 再起動時の再接続を無効化する
nmcli c m ens192 connection.autoconnect no
nmcli c m ens224 connection.autoconnect no
#-----------------------------
# bonding対象のコネクション名を一旦削除
nmcli c del ens192
nmcli c del ens224
#-----------------------------
# コネクション名の削除後の状態確認
nmcli c
nmcli d
#-----------------------------
# bonding デバイスの作成
#-----------------------------
nmcli connection add type bond autoconnect no con-name bond0 ifname bond0 mode active-backup
nmcli c
#-----------------------------
# インタフェースをbonding追加(1個目)
#-----------------------------
nmcli connection add type bond-slave autoconnect no ifname ens192 master bond0
nmcli c
nmcli -f connection c s bond-slave-ens192
#-----------------------------
# インターフェースをbonding追加(2個目)
#-----------------------------
nmcli connection add type bond-slave ifname ens224 master bond0
nmcli c
cat /proc/net/bonding/bond0
#-----------------------------
# bonding 情報
#-----------------------------
nmcli -f ipv4 c s bond0
#-----------------------------
# bonding インターフェースにIPアドレスなどを設定する
#-----------------------------
nmcli c e bond0
nmcli> set ipv4.addresses 192.168.222.99/24
nmcli> p ipv4
nmcli> verify
nmcli> save
nmcli> quit
#-----------------------------
# slave 切替わり設定
#-----------------------------
sed -i -e 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens192
sed -i -e 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens224
sed -i -e 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-bond0
#-----------------------------
# 再起動時の自動再接続を有効化
nmcli c m bond-slave-ens192 connection.autoconnect yes
nmcli c m bond-slave-ens224 connection.autoconnect yes
nmcli c m bond0 connection.autoconnect yes
#-----------------------------
# ネットワークのサービス再起動
systemctl restart NetworkManager
#-----------------------------
# nmcli 設定反映
nmcli c up bond-slave-ens192
nmcli c up bond-slave-ens224
nmcli c up bond0
#-----------------------------
# ネットワークサービス再起動
#-----------------------------
service network restart; sudo nmcli c up bond-slave-ens192
#=============================
# ■ bonding設定内容の確認
#-----------------------------
nmcli c
nmcli d
#-----------------------------
# 設定ファイルの確認
ls -ltr /etc/sysconfig/network-scripts/
cat /etc/sysconfig/network-scripts/ifcfg-bond0
cat /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens192
cat /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens224
diff /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens192 /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens224
#-----------------------------
# nmcli コマンドの内容
nmcli c show bond0
nmcli c show bond-slave-ens192
nmcli c show bond-slave-ens224
nmcli -f connection c s bond0
nmcli -f connection c s bond-slave-ens192
nmcli -f connection c s bond-slave-ens224
#=============================
# slave 切替テスト
#-----------------------------
#【切替前】
grep 'Active Slave:' /proc/net/bonding/bond0
#-----------------------------
#【slave 切替実行】
ifenslave -c bond0 ens224;nmcli c up bond-slave-ens224
#-----------------------------
#【切替後】
grep 'Active Slave:' /proc/net/bonding/bond0
#-----------------------------
#【slave 切り戻し実行】
ifenslave -c bond0 ens192;nmcli c up bond-slave-ens192
#-----------------------------
#【切り戻し後】
grep 'Active Slave:' /proc/net/bonding/bond0
#=============================
# bond0の設定を変更する場合
#-----------------------------
nmcli c m bond0 ipv4.method manual ipv4.address 192.168.222.99/24
nmcli c m bond0 ipv4.gateway 192.168.222.1
nmcli c m bond0 ipv6.method ignore
nmcli c m bond0 connection.autoconnect yes
nmcli c up bond0
nmcli c down bond0 && nmcli c up bond0
#=============================
# bonding ネットワーク速度設定
#-----------------------------
nmcli c m bond0 802-3-ethernet.auto-negotiate no 802-3-ethernet.speed 100 802-3-ethernet.duplex full
#=============================
# コネクション名を変えずにbonding
#-----------------------------
# bonding デバイスの作成
nmcli connection add type bond autoconnect no con-name bond0 ifname bond0 mode active-backup
nmcli c
#-----------------------------
# bonding にインタフェース追加
nmcli connection add type ethernet slave-type bond con-name ens161 ifname ens161 master bond0
nmcli c m ens161 connection.autoconnect yes
nmcli c up ens161
#-----------------------------
# ネットワークのサービス再起動
systemctl restart NetworkManager
#-----------------------------
cat /etc/sysconfig/network-scripts/ifcfg-ens161
diff /etc/sysconfig/network-scripts/ifcfg-ens161 /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens224
nmcli -f connection c s ens161
nmcli -f connection c s bond0
cat /proc/net/bonding/bond0
ethtool bond0
PR

更新日付

04 2025/05 06
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

RECOMMEND

プロフィール

HN:
Account
HP:
性別:
非公開
職業:
--- NODATA ---
趣味:
--- NODATA ---
自己紹介:
◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

リンク

<<【Linux】PAM設定  | HOME |  【Linux】isoのマウント>>
Copyright ©  -- LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例 --  All Rights Reserved
Design by CriCri / Photo by Melonenmann / powered by NINJA TOOLS / 忍者ブログ / [PR]