It is essential to know how to configure the network connection after installing CentOS. There are two ways to configure the network, command line and GUI. You can modify the network specifications to configure static IPs and configure dynamic network interfaces. This explanation explains how to configure the network with the following contents using the command line and Network Manager TUI. ① Configure static IP address (using command line) ② Configure dynamic (DHCP) IP address (using command line) ③ Configure static IP address (Network Manager TUI) ④ Configure dynamic IP address (Network Manager TUI) ⑤ Change the host name
# nmcli d
The list is displayed as shown below. I will explain how to change the network interface of one line.
[root@localhost centos]# nmcli d
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
virbr0 bridge Connected virbr0
lo loopback no management--
virbr0-nic tun no management--
Execute the following command and check the "network-scripts" directory.
# ls /etc/sysconfig/network-scripts/
You can confirm that the corresponding Conf file exists as shown below.
ifcfg-enp0s3
Replace the corresponding device name with network_device_name and execute the following command.
# vi /etc/sysconf ig/network-scripts/ifcfg-[network_device_name]
Add and correct the following information and save it by overwriting. ・ Additional items </ font> </ b> IPADDR = Add static IP address NETMAK = Subnet mask GATEWAY = default gateway DNS1 = Preferred DNS server DNS2 = Alternate DNS server ・ Correction items </ font> </ b> BOOTPROTO = static * → static specification </ font> * ONBOOT = yes * → Specify to automatically turn on the network when the OS starts * </ font>
TYPE=enp0s3
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static → fix
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=port1
UUID=b09ce0d7-6071-461d-b6fc-4ae261729d25
ONBOOT=yes → correction
IPADDR=Static IP address
NETMAK=sub-net mask(Settings for use)
GETWAY=default gateway(Settings for use)
DNS1=Preferred DNS server(Settings for use)
DNS2=Alternate DNS server(Settings for use)
# systemctl restart network
Execute the following command to check the list of PC interfaces.
# nmcli d
The list is displayed as shown below. I will explain how to change the network interface of one line.
[root@localhost centos]# nmcli d
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
virbr0 bridge Connected virbr0
lo loopback No management--
virbr0-nic tun no management--
Execute the following command and check the "network-scripts" directory.
# ls /etc/sysconfig/network-scripts/
You can confirm that the corresponding Conf file exists as shown below.
ifcfg-enp0s3
Replace the corresponding device name with network_device_name and execute the following command.
# vi /etc/sysconf ig/network-scripts/ifcfg-[network_device_name]
Add and correct the following information and save it by overwriting. ・ Additional items </ font> </ b> IPADDR = Add dynamic IP address NETMAK = Subnet mask GATEWAY = default gateway DNS1 = Preferred DNS server DNS2 = Alternate DNS server ・ Correction items </ font> </ b> BOOTPROTO = dhcp * → static specification </ font> * ONBOOT = yes * → Specify to automatically turn on the network when the OS starts * </ font>
TYPE=enp0s3
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp → correction
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=port1
UUID=b09ce0d7-6071-461d-b6fc-4ae261729d25
ONBOOT=yes → correction
IPADDR=Dynamic IP address
NETMAK=sub-net mask(Settings for use)
GETWAY=default gateway(Settings for use)
DNS1=Preferred DNS server(Settings for use)
DNS2=Alternate DNS server(Settings for use)
# systemctl restart network
In ① and ②, I explained how to change the network interface settings using the command line, but in ③ and ④ below, open the network manager and change the settings via GUI. I will explain. </ font>
Open NetworkManager by running the following command on the command line
# nmtui
The NetworkManager TUI will be displayed as shown below.
Open NetworkManager by running the following command on the command line
# nmtui
The NetworkManager TUI will be displayed as shown below.
Open NetworkManager by running the following command on the command line
# nmtui
The NetworkManager TUI will be displayed as shown below.
that's all.
Recommended Posts