Step 1: Identify Your Network Interface
-
Run the following command to list all network interfaces:
ip addr show
-
Identify your active network interface (e.g.,
ens33
,eth0
, etc.).
Step 2: Add the Additional IP Using nmcli
CentOS Stream 9 uses NetworkManager by default. You can add an IP with the nmcli
command.
-
Add the new IP address:
sudo nmcli connection modify <interface_name> +ipv4.addresses <new_ip>/<subnet_mask>
Example:
sudo nmcli connection modify ens33 +ipv4.addresses 192.168.1.101/24
-
Set the connection to manual (if it's not already):
sudo nmcli connection modify <interface_name> ipv4.method manual
-
Apply the changes by bringing the connection down and up:
sudo nmcli connection down <interface_name> && sudo nmcli connection up <interface_name>
Step 3: Verify the IP Binding
To ensure the new IP is bound correctly, run:ip addr show <interface_name>
You should see the new IP address listed.
Optional: Add IP via Configuration File
If you prefer to configure it manually via configuration files:
-
Navigate to the network-scripts directory:
cd /etc/sysconfig/network-scripts/
-
Edit the primary interface configuration file (replace ens33 with your interface name):
sudo nano ifcfg-ens33
-
Add the following line at the end of the file:
IPADDR2=192.168.1.101
-
Save and close the file (Ctrl + O, Enter, Ctrl + X).
-
Restart the network service:
sudo systemctl restart NetworkManager
Step 4: Test the New IP
Try pinging the new IP or accessing services bound to it:
ping 192.168.1.101