In the CentOS system installed in VM virtual machine, the default is to use DHCP to automatically obtain IP address. But I want to use this CentOS to build a small demonstration site in the LAN, which is obviously not good. So how can CentOS modify the IP address.
The author’s server also uses CentOS, which is directly set up by people who rent space. However, the local server used to use windows and rarely uses CentOS. Suddenly, he found that CentOS would not change the IP address. Baidu Google search a lot is finally solved, this article here on the detailed description and CentOS network configuration also explain in detail, hope to help is in need of this aspect of netizens.
Application scope and demonstration system
Scope of application: Linux
Demo system: centos6.4
CentOS modify IP address method
Step 1: log in to CentOS system terminal successfully.
Step 2: execute “VI / etc / sysconfig / network scripts / ifcfg-eth0” and press enter to confirm.
Step 3: modify or add corresponding code according to your own needs.
The code is as follows:
Step 4: after modification, enter “: WQ!” in VI command mode Press enter to exit VI editing mode.
Step 5: the author did the test on VM virtual machine. It will take effect immediately after modification. If you are on the host, you can execute “service network restart” to restart the network configuration.
Network configuration description
The code is as follows:
Onboot = yes # the network card is activated when the system is started, and no the network card is not activated when the system is started
Type = Ethernet # link type, usually written directly as Ethernet
Bootproto = static # set IP type. In this paper, we set static IP, or DHCP or BOOTP, which correspond to the static specified IP address, the IP address obtained through the DHCP protocol and the IP address obtained through the BOOTP protocol
IPADDR = 192.168.1.65 # if bootproto is set to static, then you need to specify a static IP address here.
Gateway = 192.168.1.9
Dns1 = 220.127.116.11? Google’s public DNS Service
Dns2 = 18.104.22.168? Google’s public dns2 service
From = yes # set the interface as the default route, no do not set the interface as the default route
IPv6 init = no # do not use IPv6
Hwaddr = 00:0c: 29: E5: D3: 3b # MAC real address of network card
Networking = yes # whether to enable the network, yes is enabled, no is not enabled.