linux7配网卡,CentOS 7 配置网卡

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 restartcentos7的网卡重启方法: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值