您的位置:首页 > 运维架构 > Linux

liunx——centos-网络管理1

2020-08-10 20:28 1126 查看

1网络接口名称规则:Network interface names

Traditionally, network interfaces in Linux are enumerated as eth0, eth1, eth2, and so on. However, the mechanism which
sets these names can cause changes to which interface gets which name as devices are added and removed.
The default naming behavior in Red Hat Enterprise Linux 7 is to assign fixed names based on firmware, device topology,
and device type.

Interface names have the following characters:
Ethernet interfaces begin with en, WLAN interfaces begin with wl, and WWAN interfaces begin with ww.
The next character(s) represents the type of adapter with an o for on-board, s for hotplug slot, and p for PCI geographic location.
Not used by default but also available to administrators, an x is used to incorporate a MAC address.
Finally, a number N is used to represent an index, ID, or port.
If the fixed name cannot be determined, the traditional names such as ethN will be used.

For example, the first embedded network interface may be named eno1 and a PCI card network interface may be named enp2s0.
The new names make it easier to distinguish the relationship between a port and its name if the user knows both, but the
trade off is that users cannot assume a system with one interface calls that interface eth0.
翻译为:网络接口名称
传统上,Linux中的网络接口被枚举为eth0、eth1、eth2等。但是,其中的机制
设置这些名称可以导致在添加和删除设备时更改接口获取的名称。
在Red Hat Enterprise Linux 7中,默认的命名行为是根据固件、设备拓扑、
和设备类型。
接口名称有以下字符:
以太网接口从en开始,WLAN接口从wl开始,WWAN接口从ww开始。
下一个字符(s)表示适配器的类型,o表示板上适配器,s表示热插拔插槽,p表示PCI地理位置。
默认情况下不使用,但管理员也可以使用,x用于合并MAC地址。
最后,数字N用于表示索引、ID或端口。
如果不能确定固定名称,则使用传统名称(如ethN)。
例如,第一嵌入式网络接口可以命名为eno1,一PCI卡网络接口可以命名为enp2s0。
如果用户知道端口和它的名称,那么新的名称可以更容易地区分端口和它的名称之间的关系
需要权衡的是,用户不能假设具有一个接口的系统调用那个接口eth0。
:en:eethernet 以太网-双绞线
wl:wirelessLAN:无线网卡
ww:WAN广域网:串行线缆

o:on-board板载网卡
s:hotplug热插拔
p:PCI接口

N:序号或者ID

示例:enp2s0
2.NetworkManager服务:
(1)网络管理器(NetworkManager)是一个动态网络的控制器与配置系统,它用于当网络设备可用时保持设备和连接开启并激活
(2)默认情况下,CentOS/RHEL 7 已安装网络管理器,并处于启用状态。
(3)查看网络管理程序的状态:systemctl status NetworkManager

(4)查看网络子管理程序的状态:systemctl status network

3.配置网络工具:配置的方法有:
(1) 命令:vim :vim /etc/sysconfig/network-scripts/ifcfg-ens32
(2)命令行: nmcli:如果没有这个命令,可以执行安装 yum -y install NetworkManager
(3)图形配置:简易图形: nmtui :

(4) 图形界面:nm-connection-editor

4.配置ip:
(1)先备份网卡配置文件,在修改:cp /etc/sysconfig/network-scripts/ifcfg-ens33 .
(2)
查看ip :ip a


子网掩码 :255.255.255.0
命令行查网关/默认路由:#ip r

命令行查dns:#cat /etc/resolv.conf

5.vim /etc/sysconfig/network-scripts/ifcfg-ens33
手动配置IP地址:

(1)ONBOOT=yes //是否启用该设备
(2)BOOTPROTO=none //根据自动获取的地址进行配置
(3)NETMASK=255.255.255.0 //子网掩码
(4)GATEWAY=192.168.57.2 //网关,也叫默认路由
(5)DNS1=192.168.57.2 这个数字1不要忘了; 域名解析。当你输入域名访问网站时,他告诉你IP地址。根据截图配置
(6)网卡信息 :NAME=ens33
(7)IPADDR=192.168.57.141
UUID=d1769473-dc3c-4cf3-9158-8798994d24bb:UUID不是网卡配置文件中必须的信息;
查看自身网卡UUID的命令:nmcli con

6.主机名:改名方式1:
(1)查看主机名:hostname

配置主机名:
hostnamectl set-hostname xaioliu

退出shell即可生效
(2) 改名方式2.
查看和配置主机名: cat /etc/hostname

更改主机名: vim /etc/hostname

重启生效:init 6

7.:网络测试工具:测试工具:
ip a //查看所有IP(ifconfig)
ip route //查看路由,查看网关
ip neigh //(了解)另一台主机ping通,查看邻居
ping 127.0.0.1:PING (Packet Internet Groper),因特网包探索器;两台虚拟机需要通信,vmnet号一定要相同

  1. ports and services
    (1)安装示例服务 :yum -y install httpd
    (2)开启:systemctl start httpd
    (3)Show TCP sockets
    查看端口:ss -tnl

    (4)端口号;是一段数字:0-65536;每一个服务程序,对应一到多个数字。通过检查端口号,确认服务是否提供
    9.初始化服务器:
    (1)最小化安装:


(2)为你的服务器配置root 密码。
(3)配置IP地址(NAT)自动获取:


10.配置yum源:方法参照前几篇文章;
11.关防火墙:
停止防火墙:systemctl stop firewalld
开机禁用防火墙:systemctl disable firewalld
查看防火墙状态:systemctl status firewalld

12.selinux:
(1) 查看selinux:getenforce:enforcing 开启(会阻止你的程序)
permissive 开启放行。
disabled 禁用
(2)临时关闭 : setenforce 0 //数字零,不是欧
(3)永久关闭: vi /etc/sysconfig/selinux

重启 :init 6 设置生效
13.安装常用程序:
yum install -y lrzsz sysstat elinks wget net-tools bash-completion vim
上传下载工具 系统状态 字符浏览器 下载工具 网络工具 自动补全
14.关机拍快照:右键点击虚拟机 →快照→拍摄快照

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: