Configure the dynamic IP.
Configure the IP address by modifying the Ifcfg-eth0 content, and enter its VI edit mode by the keyboard letter "a".
Change Onboot=no to Onboot=yes to activate the NIC.
Change Nm_controlled=yes to Nm_controlled=no.
After the modification, press "ESC" key to exit Edit mode, enter ": Wq" hit Enter to save the modified result.
Note: hwaddr and UUID can be commented or deleted.
Restart the Network service to view the dynamic IP configuration results.
Input command: Service network restart (Restart Network Service)
Input command: ifconfig-a (view network configuration)
Note: For non-root accounts, sudo is required to restart the network service.
Static configuration
Configure the static IP.
1. Also modify the Ifcfg-eth0 content, press the keyboard letter "a" to enter its vi editing mode.
Change Onboot=no to Onboot=yes
Change Nm_controlled=yes to Nm_controlled=no
Change BOOTPROTO=DHCP to Bootproto=static
Add IPAddr (IPV4): ipaddr=192.168.10.10
Add NETMASK (Subnet mask): netmask=255.255.255.0
Add Gateway: gateway=192.168.10.1
After the modification, press "ESC" key to exit Edit mode, enter ": Wq" hit Enter to save the modified result.
Note: The same hwaddr with UUID can be annotated or deleted, static IP is configured according to actual needs, above is just an example.
2.
Restart the Network service to view the dynamic IP configuration results.
Input command: Service networt Restart (Restart Network Service)
Input command: ifconfig-a (view network configuration)
Note: For non-root accounts, sudo is required to restart the network service.