How to Setup network on centos 7

 
 

After installing Centos 7, You may not able to connect network in that machine. This will happen because Ethernet interfaces are not enabled by default.This guide will help you to setup network on centos 7 .
This guide contains network configuration steps both in GUI and command mode.

Setup network on centos 7

let’s start, Type “nmcli d” command in your terminal for quick identification of Ethernet cards installed in your machine.

Here we have 2 interfaces named “enp0s17” and “enp0s18” . it might be different in your case ( Eg: em1 or p4p1 ).

GUI Mode

Recommended for beginners
Step 1 » Type this command “nmtui” to open Network manager and press enter after choosing ” Edit a connection” ( Use TAB for choosing options ) .

Step 2 » Now you can see all network interfaces, choose one and click “Edit“.

» DHCP configuration

Step 3 » For DHCP,
1. Choose “Automatic” in IPv4 CONFIGURATION.
2. Choose Automatic Connect check box.
3. Press OK and quit Network manager.

Now Restart network service by typing below command.
systemctl restart networkNow your server will get IP Address from DHCP .

» Static configuration

Step 4 » For manual IP address,
1. Choose “Manual” in IPv4 CONFIGURATION.
2. Add IP Address with Subnet , Gateway and DNS server ( Refer below image ).
3. Choose Automatic Connect check box.
4. Press OK and quit Network manager.

Now Restart network service by typing below command.
systemctl restart networkThat’s it, Interface will have static IP.

Command Mode

Step 1 » Network interface config files are located in /etc/sysconfig/network-scripts/ directory. Open ifcfg-enp0s17 file ( For interface enp0s17 ) and you can see the content like below.
[root@krizna ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s17
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s17
UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
ONBOOT=no
HWADDR=00:0C:29:A1:B5:D6
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

» DHCP configuration

Step 2 » For DHCP
Find the below lines in config File.
BOOTPROTO=none
ONBOOT=no
and replace with
BOOTPROTO=dhcp
ONBOOT=yes
Now Restart network service by typing below command.
systemctl restart networkNow your server will get IP Address from DHCP

» Static configuration

Step 3 » For Static IP.
Find the below lines in config File.
BOOTPROTO=none
ONBOOT=no
and replace with
BOOTPROTO=static
ONBOOT=yes
And add the below lines at the end of the file.
IPADDR=172.27.0.32
NETMASK=255.255.255.0
GATEWAY=172.27.0.1
DNS1=172.27.0.5
File will look like below after changes.
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s17
UUID=f0c5b37d-299a-43cb-b74b-618bb252d129
ONBOOT=yes
HWADDR=00:0C:29:A1:B5:CC
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.5

Now Restart network service by typing below command.
systemctl restart networkNow Interface will have static IP.
Additionally you can use /etc/sysconfig/network file for hostname and DNS .
HOSTNAME=server.krizna.com
DNS1=192.168.1.5
DNS2=8.8.8.8
SEARCH=krizna.com

Have a nice day

Setup network on centos 7的更多相关文章

  1. Configuring Network in CentOS 6.3 Virtual Box + Screenshots

    Configuring Network in CentOS 6.3 Virtual Box + Screenshots Posted: May 23, 2013 in Uncategorized Ta ...

  2. How to setup multimedia on CentOS 7

    You will need to also install the EPEL repository as nux-dextop depends on this for some of its pack ...

  3. qemu vm setup network(ssh) with buildroot

    1, build buildroot with buildroot.config, that is 'make qemu_x86_64_defconfig' + some packages, sshd ...

  4. CentOS报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

    今天安装完带图形界面的CentOS 7后,在Terminal中运行yum安装命令时报了以下错误: Could not retrieve mirrorlist http://mirrorlist.cen ...

  5. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

     今天安装完带图形界面的CentOS 7后,在Terminal中运行yum安装命令时报了以下错误: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...

  6. centos7的网络管理(参考使用)

    How to Setup network on centos 7 Posted krizna Centos, Centos 7   After installing Centos 7, You may ...

  7. procedure of intall and setup centos 6.5

    select webserver install option,and select ,uncheck the postgresql option selected some “… platform” ...

  8. Centos7 编译安装 Nginx Mariadb Asp.net Core2 (实测 笔记 Centos 7.3 + Openssl 1.1.0h + Mariadb 10.3.7 + Nginx 1.14.0 + Asp.net. Core 2 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  9. Centos 02 操作系统 & Linux安装

    操作系统的概念 操作系统是沟通使用者和硬件之间传递信息的工具或程序,是电子计算机系统负责支撑应用程序运行环境以及用户操作环境的基础系统软件 硬件 ==> 系统核心 ==> 命令解释器she ...

随机推荐

  1. 【转】对抗拖库 ―― Web 前端慢加密

    0×00 前言 天下武功,唯快不破.但密码加密不同.算法越快,越容易破. 0×01 暴力破解 密码破解,就是把加密后的密码还原成明文密码.似乎有不少方法,但最终都得走一条路:暴力穷举.也许你会说还可以 ...

  2. 关于Function.prototype.bind

    bind()方法会创建一个新函数,称为绑定函数.当调用这个绑定函数时,绑定函数会以创建它时传入bind()方法的第一个参数作为 this,传入 bind() 方法的第二个以及以后的参数加上绑定函数运行 ...

  3. 众安「尊享e生」果真牛的不可一世么?

    近日,具有互联网基因的.亏损大户(成立三年基本没盈利,今年二季度末亏损近4亿,你能指望它多厉害?).财产险公司—众安推出“尊享e生”中高端医疗保险(财险公司经营中高端医疗真的很厉害?真的是中高端医疗险 ...

  4. php json_encode中文unicode问题

    php调用json_encode将中文字符串存入mysql后读取出来有问题,发现存进去的时候把'\'给去掉了.解决方法是调用json_encode时候后面加JSON_UNESCAPED_UNICODE ...

  5. JAVA课程实验报告 实验五 Java网络编程及安全

    北京电子科技学院(BESTI) 实     验    报     告 课程:Java程序设计  班级:1353  姓名:韩玉琪  学号:20135317 成绩:             指导教师:娄嘉 ...

  6. android项目中使用开源数据库litepal

    下载地址 https://github.com/LitePalFramework/LitePal 参考文档 http://blog.csdn.net/guolin_blog/article/detai ...

  7. MATLAB - 图像基本操作

    1.读入一幅图像 I = imread('lena.jpg');%给出图片路径即可,I是一个三维矩阵 J = rgb2gray(I); figure, imshow(I), figure, imsho ...

  8. C#中TreeView与数据库绑定

    protected void CreateTreeView() { TreeNode rootNode = new TreeNode(); rootNode.Text = "全部" ...

  9. Python全栈--7.3--模块补充configparser--logging--subprocess--os.system--shutil

    模块补充: 一.configparser用于处理特定格式的文件,其本质是利用open来操作文件 继承到2版本 configparser 实现了更多智能特征,更有壳预见性,新的应用更偏好这个版本, 处理 ...

  10. Xcode 设置代码不自动换行

    "command + ,"打开设置界面后,找到"Text Editing" 然后选择"Indentation", 最后找到"lin ...