How do you set up the IP address on AlmaLinux?
To set up the IP address for AlmaLinux, you can follow these steps:
- Open the terminal and log in as the root user.
- Use the following command to edit the network configuration file:
- Edit the configuration file for eth0 located in /etc/sysconfig/network-scripts.
- The eth0 here is the default network card name; if you have other network cards, you can replace it with the corresponding name.
- In the editor, locate the following line and make the following modifications:
- BOOTPROTO set to static
ONBOOT enabled
IP address is 192.168.1.100
Subnet mask is 255.255.255.0
Gateway set to 192.168.1.1 - The IP address, subnet mask, and gateway here should be configured according to your network environment.
- Save and close the file.
- Execute the following command to restart the network service:
- Restart the network using systemctl.
- To ensure that the network configuration takes effect, you can use the following command to check if the IP address is properly configured.
- Display the IP address of the eth0 interface.
- If you are using a different network card name, you need to replace eth0 with the corresponding name.
In this way, you have successfully set up the IP address for AlmaLinux.