How to configure static IP addresses in CentOS 7

Source: Internet
Author: User

How to configure static IP addresses in CentOS 7

When I was a beginner in Linux, I encountered a problem, that is, configuring the IP address of the NIC. The collection of relevant information was successfully configured. This is now recorded for convenience of memory.
Use the CD command to jump to the corresponding configuration file. The configuration command is cd/etc/sysconfig/network-scripts/

[root@localhost ~]# cd /etc/sysconfig/network-scripts/

If you do not know the file, use the ls command to view it.

[root@localhost network-scripts]# ls ifcfg-eno16777736  ifdown-ib    ifdown-ppp       ifdown-tunnel  ifup-ib    ifup-plusb   ifup-Team         network-functionsifcfg-lo           ifdown-ippp  ifdown-routes    ifup           ifup-ippp  ifup-post    ifup-TeamPort     network-functions-ipv6ifdown             ifdown-ipv6  ifdown-sit       ifup-aliases   ifup-ipv6  ifup-ppp     ifup-tunnelifdown-bnep        ifdown-isdn  ifdown-Team      ifup-bnep      ifup-isdn  ifup-routes  ifup-wirelessifdown-eth         ifdown-post  ifdown-TeamPort  ifup-eth       ifup-plip  ifup-sit     init.ipv6-global

The first ifcfg-enoxxxxxxxx (here x indicates a number) is the configuration file, which can be used in the vi editor. Press I to enter the editing mode and modify the file.

[root@localhost network-scripts]# vi ifcfg-eno16777736 TYPE="Ethernet"BOOTPROTO="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="eno16777736"UUID="718afcbf-931e-4c0c-a23f-bfc3c13023c2"DEVICE="eno16777736"ONBOOT="yes"IPADDR0="xxx.xxx.xxx.xxx"NETMASK="xxx.xxx.xxx.xxx"GATEWAY="xxx.xxx.xxx.xxx"


After editing, enter: wq! Save and exit, and then enter

/etc/init.d/network restart

The static IP Address Configuration is successfully saved and takes effect.

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.