Original link: http://blog.csdn.net/johnnycode/article/details/40624403
This study is mainly for Centos 7.0.1406 version to learn to organize!
If you use VirtualBox to configure CentOS then please refer to my article CentOS 7 learning static IP settings (cont.)
1, edit the Ifcfg-eth0 file, vim minimized installation is not installed, need to install the self-description.
[plain] view plain copy
- # Vim/etc/sysconfig/network-scripts/ifcfg-eth0
2, modify the following content
[plain] view plain copy
- bootproto= "Static" #dhcp改为static
- onboot= "Yes" #开机启用本配置
- ipaddr=192.168.7.106 #静态IP
- gateway=192.168.7.1 #默认网关
- netmask=255.255.255.0 #子网掩码
- dns1=192.168.7.1 #DNS Configuration
3. Effect after modification
[plain] view plain copy
- #]# cat/etc/sysconfig/network-scripts/ifcfg-eth0
- hwaddr= "00:15:5d:07:f1:02"
- type= "Ethernet"
- bootproto= "Static" #dhcp改为static
- defroute= "yes"
- peerdns= "yes"
- peerroutes= "yes"
- ipv4_failure_fatal= "No"
- ipv6init= "yes"
- ipv6_autoconf= "yes"
- ipv6_defroute= "yes"
- ipv6_peerdns= "yes"
- ipv6_peerroutes= "yes"
- ipv6_failure_fatal= "No"
- name= "eth0"
- uuid= "bb3a302d-dc46-461a-881e-d46cafd0eb71"
- onboot= "yes" #开机启用本配置
- ipaddr=192.168.7.106 #静态IP
- gateway=192.168.7.1 #默认网关
- netmask=255.255.255.0 #子网掩码
- dns1=192.168.7.1 #DNS configuration
4. Restart the Network Service
[plain] view plain copy
- # Service Network Restart
5, see the effect after the change, Centois 7 no longer use ifconfig instead of using the IP command to view network information.
[plain] view plain copy
- # IP Addr
- 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN
- Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
- inet 127.0.0.1/8 Scope host Lo
- Valid_lft Forever Preferred_lft Forever
- INET6:: 1/128 Scope Host
- Valid_lft Forever Preferred_lft Forever
- 2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU qdisc pfifo_fast State UNKNOWN Qlen 1000
- Link/ether 00:15:5d:07:f1:02 BRD FF:FF:FF:FF:FF:FF
- inet 192.168.7.106/24 BRD 192.168.7.255 Scope Global eth0
- Valid_lft Forever Preferred_lft Forever
- Inet6 FE80::215:5DFF:FE07:F102/64 Scope link
- Valid_lft Forever Preferred_lft Forever
Centos 7 Learning static IP settings