In fact, after the system is installed, you need to change two places. One is the computer name and the other is the IP address.
Where can I change the computer name?
The configuration file of the centos computer name is network VI/etc/sysconfig/network under the/etc/sysconfig/directory.
Networking = Yes
Hostname = linux123 [change my computer name to linux123]
Change computer OS IP Address
Centos network configuration file is/etc/sysconfig/network-scripts directory under the ifcfg-eth0 [if you have multiple NICs, ifcfg-eth 0 ifcfg-eth1, etc]
Edit this configuration file VI/etc/sysconfig/network-scripts/ifcfg-eth0
This is my configuration file
Device = eth0
Bootproto = static
Onboot = Yes
Type = Ethernet
Userctl = No
# Gateway = Yes
Dns1 = 8.8.8.8
Dns2 = 114.114.114.114
Ipv6init = No
Hwaddr = 00: 0C: 29: Ea: 7f: DF
Ipaddr = 192.168.1.240
Netmask = 255.255.255.0
Gateway = 192.168.1.1
Device = eth0 [Nic alias]
Bootproto = static [You can set it to a static IP address or set it to DHCP for Automatic Retrieval]
Onboot = Yes [start with system]
Type = Ethernet [type Ethernet]
Userctl = No [This is unknown. I only know that this configuration file is available when I compile it]
# Gateway = Yes
Dns1 = 8.8.8.8 [preferred DNS]
Dns2 = 114.114.114.114 [Backup dns]
Ipv6init = No [whether IPv6 is supported]
Hwaddr = 00: 0C: 29: Ea: 7f: DF [physical address]
Ipaddr = 192.168.1.240 [set the IP address of this computer to 192.168.1.240]
Netmask = 255.255.255.0 [mask]
Gateway = 192.168.1.1 [gateway]
Save and exit the restart Test
[[Email protected] ~] # Hostname
Linux123
[[Email protected] ~] #
[[Email protected] ~] # Ifconfig
Eth0 link encap: Ethernet hwaddr 00: 0C: 29: Ea: 7f: DF
Inet ADDR: 192.168.1.240 bcast: 192.168.1.255 mask: 255.255.255.0
Inet6 ADDR: fe80: 20c: 29ff: feea: 7fdf/64 scope: Link
Up broadcast running Multicast MTU: 1500 Metric: 1
RX packets: 71 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 96 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX Bytes: 7452 (7.2 kib) TX Bytes: 11422 (11.1 kib)
Lo link encap: local loopback
Inet ADDR: 127.0.0.1 mask: 255.0.0.0
Inet6 ADDR: 1/128 scope: Host
Up loopback running MTU: 16436 Metric: 1
RX packets: 4 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 4 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX Bytes: 240 (240.0 B) TX Bytes: 240 (240.0 B)