分享

CentOS 7 配置网卡

 rongq2007 2019-08-14

VM安装了一个Linux系统CentOS,但是安装后发现ping www.baidu.com 报错 。查了一下发现需要配置网卡。

1.首先需要进入目录 /etc/sysconfig/network-scripts

这里我的centos的 iso版本是:CentOS-7-x86_64-DVD-1708.iso。进入目录之后可以看到有个ifcfg-ens33的文件。我们需要对这个文件做些修改。

2.vi ifcfg-ens33

这里主要需要修改几个地方。

a.由于我要配置的静态的IP,所以BOOTPROTO=static。

b.ONBOOT=yes。默认为no,开启网络连接。 

d.IPADDR,NETMASK,GATEWAY,DNS1,DNS2参考修改

7.重启network service

service network restart.

8.测试ping

ping www.baidu.com

注:这里我VM里面的网卡配置的桥接方式。

centos7的网卡重启方法

1、centos6的网卡重启方法:service network restart
      
centos7的网卡重启方法:systemctl restart network

2关闭防火墙并设置开机不启动

查看防火墙状态:systemctl status firewalld.service
关闭:systemctl stop firewalld
开启:systemctl start firewalld
开机自动关闭:systemctl disable firewalld
开机自动启动:systemctl enable firewalld
查看开机是否启动:chkconfig --list|grep network(RHLE6)

firewalld 基本使用
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld

centos6

关闭虚拟机防火墙:

关闭命令:  service iptables stop

永久关闭防火墙:chkconfig iptables off

两个命令同时运行,运行完成后查看防火墙关闭状态

service iptables status

1 关闭防火墙-----service iptables stop 

2 启动防火墙-----service iptables start 

3 重启防火墙-----service iptables restart 

4 查看防火墙状态--service iptables status 

5 永久关闭防火墙--chkconfig iptables off 

6 永久关闭后启用--chkconfig iptables on

 ———————————————— 

SELinux

  • 临时关闭SELinux 
    setenforce 0

  • 临时打开SELinux 
    setenforce 1

  • 查看SELinux状态 
    getenforce

  • 开机关闭SELinux 
    编辑/etc/selinux/config文件,如下图,将SELINUX的值设置为disabled。下次开机SELinux就不会启动了。

  安装vim

yum install -y vim*

Vim 的全局配置一般在 /etc/vim/vimrc 或者 /etc/vimrc

VIM配置入门

centos7 Mariadb5.5升级到Mariadb10.2

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多