English
Rocky Linux 9.6 Complete Guide to Adding a Second Network Card and Configuring a Static IP

Scenario Description
Add a second network adapter (Network Adapter 2) for Rocky Linux 9.6 in a VMware virtual machine, and configure a static IP address.
Operation process
1. Check the current network status
First, check the existing network card configuration:
bash
ll /etc/NetworkManager/system-connections/Output:
total 4
-rw--- 1 root root 277 Jul 21 10:19 ens32.nmconnectionView current network connections:
bash
nmcli con showOutput:
NAME UUID TYPE DEVICE
ens32 bf4982a2-6102-3e47-abb9-3670f1272538 ethernet ens32
Wired connection 1 77bc6937-cee1-3f51-8076-62e6e4ceec6c ethernet ens34
lo 12212a3c-b694-4408-9544-0387a4b02997 loopback loYou can see that the system has already recognized the new network card.ens34, and automatically created a temporary connection "Wired connection 1".
2. Create a persistent connection for the new network card
Use nmcli Command to create a new connection configuration:
bash
nmcli connection add type ethernet con-name ens34 ifname ens34Output:
Connection 'ens34' (eee4a6d3-4264-4dbc-afb9-9671595ce0f4) successfully added.At this point, view the configuration file directory:
bash
ll /etc/NetworkManager/system-connections/Output:
total 8
-rw--- 1 root root 277 Jul 21 10:19 ens32.nmconnection
-rw--- 1 root root 182 Jul 21 14:31 ens34.nmconnection3. Configure a static IP address
Edit the configuration file and set a static IP:
bash
vim /etc/NetworkManager/system-connections/ens34.nmconnectionConfiguration content:
ini
[connection]
id=ens34
uuid=eee4a6d3-4264-4dbc-afb9-9671595ce0f4
type=ethernet
interface-name=ens34
[ethernet]
[ipv4]
address1=172.16.28.221/16
gateway=172.17.0.1
method=manual
[ipv6]
addr-gen-mode=default
method=auto
[proxy]4. Delete temporary connection
Delete the temporary connections automatically created by the system to avoid conflicts:
bash
nmcli connection delete "Wired connection 1"Output:
Connection 'Wired connection 1' (77bc6937-cee1-3f51-8076-62e6e4ceec6c) successfully deleted.5. Reload and activate the configuration
Reload NetworkManager configuration:
bash
nmcli con reloadView connection status:
bash
nmcli con showOutput:
NAME UUID TYPE DEVICE
ens32 bf4982a2-6102-3e47-ab9b-3670f1272538 ethernet ens32
ens34 eee4a6d3-4264-4dbc-afb9-9671595ce0f4 ethernet ens34
lo 12212a3c-b694-4408-9544-0387a4b02997 loopback lo6. Verify configuration
View device status:
bash
nmcli device statusOutput:
DEVICE TYPE STATE CONNECTION
ens32 ethernet connected ens32
ens34 ethernet connected ens34
lo loopback connected (externally) loView IP address configuration:
bash
ip aOutput (key parts):
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:9e:31:9e brd ff:ff:ff:ff:ff:ff
altname enp2s0
inet 172.16.4.221/16 brd 172.16.255.255 scope global noprefixroute ens32
valid_lft forever preferred_lft forever
3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:9e:2a:d9 brd ff:ff:ff:ff:ff:ff
altname enp2s2
inet 172.16.28.221/16 brd 172.16.255.255 scope global noprefixroute ens34
valid_lft forever preferred_lft forever
inet6 fe80::80ea:f978:ffdf:954d/64 scope link noprefixroute
valid_lft forever preferred_lft foreverKey considerations
1. Do not directly delete temporary connections
If the network card already has a temporary connection (such as "Wired connection 1"), you should:
Create first New persistent connection
Delete again Temporary connection
Or directly rename and modify the temporary connection:
bash
nmcli connection modify "Wired connection 1" con-name ens34
nmcli connection modify ens34 ipv4.addresses 172.16.28.221/16
nmcli connection modify ens34 ipv4.gateway 172.17.0.1
nmcli connection modify ens34 ipv4.method manual
nmcli connection up ens342. Configuration file permissions
NetworkManager configuration file permissions must be 600:
bash
chmod 600 /etc/NetworkManager/system-connections/ens34.nmconnection3. Network Planning
The first network card
ens32:172.16.4.221/16The second network card
ens34:172.16.28.221/16
Two network cards are on different network segments, achieving network isolation.
Common Commands Quick Reference
| Command | Explanation |
|---|---|
nmcli con show | View all connections |
nmcli device status | Check device status |
nmcli con reload | Reload the configuration file |
nmcli con up <连接名> | Activate Connection |
nmcli con down <连接名> | Disable connection |
nmcli con delete <连接名> | Delete connection |
ip a | View IP address |
Summary
Key steps to add a second network card and configure a static IP in Rocky Linux 9.6:
Confirm that the network card is recognized:
nmcli con showView deviceCreate a persistent connection:
nmcli connection addConfigure a static IP: Edit configuration file settings
method=manualClean up temporary connections: Delete "Wired connection 1"
Reload configuration:
nmcli con reloadVerify network connectivity:
ip aandpingTest
Through the above steps, you can successfully configure static IPs for multiple NICs on a Rocky Linux 9.6 server to meet production environment requirements.