Static IP settings for Centos 7 Learning
Using a virtual machine to learn Linux may be the simplest and most effective way. I have previously written an article about Centos 7 static configuration and record it this time. How to Use VirtualBox and how to install Centos in VirtualBox is not covered in this article.
VirtualBox Network Mode
The four network modes of VirtualBox are not discussed. If you are interested, you can quickly understand the four network connection modes of VirtualBox. In this article, select the bridge mode.
1. Current System Environment:
shell># uname -aLinux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linuxshell># cat /etc/redhat-releaseCentOS Linux release 7.1.1503 (Core)
2. Operation steps: a. Select Virtual Machine> network> connection mode> bridge Nic B. Select available Nic for the current physical host, the specific options are based on your Nic settings. How can I translate the Interface Name?
Set static IP
If you are interested in the official answers to static IP settings, please refer to the official WIKI guide. The configuration scheme is provided here. You need to configure two places. Administrator (root) permission is required for all operations!
Configuration File
Find ifcfg-* in the/etc/sysconfig/network-scripts PATH, * represents the specific network card, this article modifies the network card is ifcfg-enp0s3, you may be a ifcfg-eth0, except for the ONBOOT and BOOTPROTO modifications, the other items are added. The modified content can be found below.
TYPE = EthernetDEFROUTE = yesPEERDNS = yesPEERROUTES = route = notes6init = route = canonical = noNAME = enp0s3UUID = queue = enp0s3 # static assignmentONBOOT = yes # Start BOOTPROTO static # static IPIPADDR = 192.168.1.151 # local address NETMASK = 255.255.255.0 # subnet mask GATEWAY = 192.168.1.1 # Default GATEWAY
2. We recommend that you configure DNS in/etc/sysconfig/network, which is simple and straightforward.
# Created by anacondaDNS1=192.168.1.1DNS2=8.8.8.8
Reset Network Configuration
shell># service network restartRestarting network (via systemctl): [ OK ]
View network configurations
shell># ip addr...2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:0e:35:27 brd ff:ff:ff:ff:ff:ff inet 192.168.1.151/24 brd 192.168.1.255 scope global enp0s3...
OK. Now the Centos 7 network is configured. What about you :)