centos7 为服务器设置静态内网IP
2016-10-18 14:55
204 查看
Setting a Static IP in a CentOS 7 Minimal Installation
In order to set the network adapter and get get CentOS to communicate on the network the Ethernet adapter will need to be configured. In this lesson I will set a static IP address for the network adapter. To view a list of your network adapters use the command ip addr.
The configuration file for the network adapter should be located at /etc/sysconfig/network-scripts/ifcfg-enp0s3. With the minimal installation of CentOS there are not many options available to configure the network adapter. One option is to use the vi editor
or nano to configure ifcfg-enp0s3. Another option is to use the nmtui utility to edit the network adapter.
Modify ifcfg-enp0s3 using nmtui
If you plan on configuring the network adapter using the nmtui utility open a terminal and enter the command nmtuiA utility application opens within the terminal that
will allow you to configure the network adapters. With Edit a Connection selected, press Enter. Your network adapter should be listed, for example enp0s3 is what is listed on my computer. Using the arrow keys, select Edit and press Enter. To allow the adapter
to fire up at startup, use the spacebar to place an “x” in the Automatically connect option. If you wish to set a static IP address you can do so by selecting the IP version and editing it.
Modify ifcfg-enp0s3 using vi or nano
If you are familiar with using the vi editor you can also modify the ifcf-eth0 file using vi. To use this option, type the following command in the prompt: vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
You can also use nano as a text editor. If you are newer to Linux this editor has less of a learning curve than vi. Nano will need to be installed using the command:
yum install nanoOnce installed, to use nano to edit the file type:
nano /etc/sysconfig/network-scripts/ifcfg-enp0s3
Here is an example of the file using 192.168.1.2 as the static IP address.
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV$_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=”WHAT EVER IS YOUR COMPUTER’s UUID”
ONBOOT=yes
HWADDR=”WHATEVER IS YOUR COMPUTER’S MAC ADDRESS”
IPADDR=192.168.1.2
PREFIX=24
DNS=192.168.1.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
Restarting the networking service
You may have to restart the network adapter or the machine. To restart the network adapter use the following command:service network restart.
Using ifconfig
If you wish to install the common networking tools you can now install the net-tools package using the following command:yum install net-tools
This will allow you to view your network adapters using the terminal command:
ifconfig
相关文章推荐
- Centos 7 学习之静态IP设置
- CentOS 6.4设置静态IP不生效解决方法
- centos静态IP设置
- Centos 7静态IP设置
- Linux虚拟机Centos 设置固定的静态IP
- VMware中CentOS设置静态IP
- centos虚拟机NAT静态IP设置
- vm centos 设置静态ip
- centos双线双ip服务器路由设置方法
- Centos设置静态IP
- centos 6.5 设置静态ip
- Centos7下设置静态IP 环境VMWare12.5.0
- CentOS系统安装完毕后,网络连接方式为NAT,系统无法上网或IP设置成静态后无法上
- VWMare CentOS 6.5 静态IP设置
- centos设置静态IP
- centos设置静态IP后不能范文外网
- Centos 7 学习之静态IP设置
- Centos 7 静态IP设置
- centos 设置静态IP
- Centos 7 学习之静态IP设置