Centos 7 Learning static IP settings

Source: Internet
Author: User

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 PlainCopy 
    1. # Vim/etc/sysconfig/network-scripts/ifcfg-eth0

2, modify the following content

[Plain]View PlainCopy  
    1. bootproto= "Static" #dhcp改为static
    2. onboot= "Yes" #开机启用本配置
    3. ipaddr=192.168.7.106 #静态IP
    4. gateway=192.168.7.1 #默认网关
    5. netmask=255.255.255.0 #子网掩码
    6. dns1=192.168.7.1 #DNS Configuration

3. Effect after modification

[Plain]View PlainCopy 
  1. #]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
  2. Hwaddr= "00:15:5d:07:f1:02"
  3. Type= "Ethernet"
  4. bootproto= "Static" #dhcp改为static
  5. Defroute= "Yes"
  6. Peerdns= "Yes"
  7. Peerroutes= "Yes"
  8. Ipv4_failure_fatal= "No"
  9. ipv6init= "Yes"
  10. ipv6_autoconf= "Yes"
  11. Ipv6_defroute= "Yes"
  12. Ipv6_peerdns= "Yes"
  13. Ipv6_peerroutes= "Yes"
  14. Ipv6_failure_fatal= "No"
  15. Name= "Eth0"
  16. Uuid= "Bb3a302d-dc46-461a-881e-d46cafd0eb71"
  17. onboot= "Yes" #开机启用本配置
  18. ipaddr=192.168.7.106 #静态IP
  19. gateway=192.168.7.1 #默认网关
  20. netmask=255.255.255.0 #子网掩码
  21. dns1=192.168.7.1 #DNS Configuration

4. Restart the Network Service

[Plain]View PlainCopy 
    1. # 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 PlainCopy 
  1. # IP Addr
  2. 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN
  3. Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
  4. inet 127.0.0.1/8 Scope host Lo
  5. Valid_lft Forever Preferred_lft Forever
  6. INET6:: 1/128 Scope Host
  7. Valid_lft Forever Preferred_lft Forever
  8. 2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU qdisc pfifo_fast State UNKNOWN Qlen 1000
  9. Link/ether 00:15:5d:07:f1:02 BRD FF:FF:FF:FF:FF:FF
  10. inet 192.168.7.106/24 BRD 192.168.7.255 Scope Global eth0
  11. Valid_lft Forever Preferred_lft Forever
  12. Inet6 FE80::215:5DFF:FE07:F102/64 Scope link
  13. Valid_lft Forever Preferred_lft Forever

Static IP is set at installation but only 127.0.0.1 IP address when using the Ifconfig command

At this time see if there is a Ifcfg-eth0 file under the/etc/sysconfig/network-scripts directory if there is no file to see if there is a ifcfg-beginning

My system exists ifcfg-eno16777736 such a file

More ifcfg-eno16777736

[Email protected] network-scripts]$ more ifcfg-eno16777736
Type=ethernet
Bootproto=none
Defroute=yes
Ipv4_failure_fatal=no
Ipv6init=yes
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_failure_fatal=no
name=eno16777736
Uuid=7170eda3-8183-41fc-b0b8-ee924d05ddc2
Onboot=no
ipaddr0=192.168.0.88
Prefix0=24
hwaddr=00:0c:29:61:34:7d
Ipv6_peerdns=yes
Ipv6_peerroutes=yes

Just for the IP information I added when I installed the system

At this point, use the command CP ifcfg-eno16777736 Ifcfg-eth0 to create the Ifcfg-eth0 file and change the Onboot=no in the content to Onboot=yes

Execute Command Service network restart

Execute ifconfig The correct network information appears

Eno16777736:flags=4163<up,broadcast,running,multicast> MTU 1500
inet 192.168.0.88 netmask 255.255.255.0 broadcast 192.168.0.255
Inet6 fe80::20c:29ff:fe61:347d Prefixlen ScopeID 0x20<link>
Ether 00:0c:29:61:34:7d Txqueuelen (Ethernet)
RX Packets 102 Bytes 10385 (10.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets Bytes 13681 (13.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


Lo:flags=73<up,loopback,running> MTU 65536
inet 127.0.0.1 netmask 255.0.0.0
Inet6:: 1 prefixlen ScopeID 0x10Loop Txqueuelen 0 (Local Loopback)
RX Packets 818 Bytes 71132 (69.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets 818 Bytes 71132 (69.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

If the installation environment is host-only for VM VMS, you want to surf the Internet in the virtual machine

Find the network card in the win environment Vmnet1 to see his IP address through the property TCP/IP protocol

Assuming this is 192.168.0.12 and the IP set in the virtual machine is ipaddr0=192.168.0.88 need to add the gateway to the IP address of the current win Vmnet1 in Ifcfg-eth0

That is, add geteway=192.168.0.12

On win must have a network card such as My notebook for the wireless card right-click Properties Advanced Allow other networks to connect through this computer's internet to hook up and down the box to select the Vmnet network card

Ok if pop-up confirm select No

To view the wireless network card DNS server through the Ipconfig-all command such as my

Ethernet Adapter Wireless network connection:
       connection-specific DNS Suffix  .:
    &NBSP ;   Description ........... : Broadcom 802.11n Network
        physical Address ...: 08-3e-8e-4a-38-ab
  &NBSP ;     DHCP Enabled ..... : Yes
        autoconfiguration Enabled ...: Yes
        IP address. ....: 192.168.1.100
        Subnet Mask ...........:255.255.255.0
&N Bsp       Default Gateway ..... . : 192.168.1.1
        DHCP Server ...: 192.168.1.1
      &NBSP ; DNS Servers ........... : 211.162.66.66
                            &NBSP ;               211.162.77.77

Add a DNS server to Ifcfg-eth0 I've got two here.

Add two lines

dns1=211.162.66.66

dns2=211.162.77.77

At this point, the Linux Restart Service network restart on the virtual machine

Ping www.baidu.com Success

http://blog.csdn.net/johnnycode/article/details/40624403

Centos 7 Learning static IP settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.