NIC绑定操作中,如何确定为bond0分配的IP地址?
How to Assign an IP to bond0 & Confirm It During NIC Bonding
Hey there! Let’s tackle your two questions about bond0 IP assignment clearly—NIC bonding can feel a bit tricky at first, but we’ll break it down step by step.
1. Which IP should you assign to bond0?
Think of bond0 as a virtual "super" network interface that replaces your individual physical NICs (like eth0, eth1) for all network traffic. The IP rules here are almost identical to a regular physical interface:
- If you’re using static IPs: Pick an available IP from the same subnet as your original physical NICs. The easiest approach is to reuse the IP that was previously assigned to one of your physical NICs—once bonded, those physical interfaces won’t need their own IPs anymore. Just double-check the IP isn’t already claimed by another device on your network.
- If you’re using DHCP: You don’t need to manually select an IP—just configure bond0 to pull one from your DHCP server. Your physical NICs won’t need their own DHCP configs once they’re set as slaves to bond0.
- Critical note: After bonding, your physical slave interfaces should only have link-layer settings (no IP, no gateway) — all network traffic will route through bond0.
2. How to confirm the IP during NIC bonding setup
Here’s a practical, step-by-step way to lock in the IP while setting up bonding:
- Map your network context first:
- Run
ip addrto check the subnet, gateway, and existing IPs of your physical NICs. For example, if your eth0 uses192.168.1.50/24with gateway192.168.1.1, your bond0 IP should live in the192.168.1.x/24range. - Test if your chosen static IP is free with
ping <your-chosen-ip>— if there’s no response, it’s safe to use.
- Run
- Configure bond0’s IP directly in its config file:
- For RHEL/CentOS systems, edit
/etc/sysconfig/network-scripts/ifcfg-bond0with your static IP details (example below):TYPE=Bond BONDING_MASTER=yes NAME=bond0 DEVICE=bond0 ONBOOT=yes BOOTPROTO=static IPADDR=192.168.1.50 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 BONDING_OPTS="mode=active-backup miimon=100" - For Debian/Ubuntu with Netplan, create a config file like
/etc/netplan/00-bonding.yaml:network: version: 2 ethernets: eth0: dhcp4: no eth1: dhcp4: no bonds: bond0: interfaces: [eth0, eth1] addresses: [192.168.1.50/24] gateway4: 192.168.1.1 parameters: mode: active-backup miimon: 100
- For RHEL/CentOS systems, edit
- Set up your slave NICs:
- For each physical NIC (eth0, eth1), edit their config files to remove IP settings and mark them as slaves to bond0. For example, in RHEL/CentOS
ifcfg-eth0:TYPE=Ethernet NAME=eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes
- For each physical NIC (eth0, eth1), edit their config files to remove IP settings and mark them as slaves to bond0. For example, in RHEL/CentOS
- Verify the IP after setup:
- Restart your network service:
systemctl restart network(RHEL/CentOS) ornetplan apply(Debian/Ubuntu). - Run
ip addr show bond0— you should see your assigned IP listed under the interface.
- Restart your network service:
A quick reminder: Bonding modes (like active-backup or 802.3ad) don’t affect how you assign the IP — the IP always lives on bond0, regardless of the mode you choose.
内容的提问来源于stack exchange,提问作者pasha ahmed
相关产品推荐
相关产品推荐

