Linux~~~网络管理(配置)-2020.12.4-5

网络管理

简介

Linux网络接口名称规则

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.

en :eeuhernet 以太网-双绞线

wl:wirelessLAN:无线网卡

ww:WAN广域网:串行线缆

o :on-board 板载网卡

s :hotplug 热插拔

p: PCL接口

N :序号或者ID

示例 :enp2s0

NetworkManager服务

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

[root@localhost ~]# systemctl status NetworkManager

查看网络子管理程序的状态:

[root@localhost ~]# systemctl status network
配置网络的工具
配置的方法

图形
命令

命令行配置

配置文件:vim
注意网卡编号 可用 ip a 或 ls /etc/sysconfig/network-scripts/查询
网卡名:ens33

[root@localhost ~]# [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

在这里插入图片描述ipv4有43亿个地址 ipv6有2^128个地址 ipv5没有被使用
IPV6(IP协议第六代)正在试运行,在学校实验室和科研室会出现,也可删除或注释

命令行:

[root@localhost ~]# nmcli device  -->网络管理命令行

如果没有这个命令,可以执行安装 yum -y install NetworkManager

图形配置

简易图形:

[root@localhost ~]# nmtui

在这里插入图片描述
图形界面:nm-connection-editor
在这里插入图片描述

配置网络参数

配置IP
配置网卡参数

先备份网卡配置文件,再修改

[root@qianfeng ~]# cp   /etc/sysconfig/network-scripts/ifcfg-ens33   .  -->(.当前路径)

查看本机的自动获取的IP截图或自行输入命令查询
在这里插入图片描述
命令行查看IP:

[root@localhost ~]# ip a

在这里插入图片描述
子网掩码: 255.255.255.0

命令行查网关/默认路由:

[root@localhost ~]# ip r

在这里插入图片描述
命令行查dns

[root@localhost ~]# cat /etc/resolv.conf

在这里插入图片描述

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

在这里插入图片描述

顺序不重要
ONBOOT=yes – > 开机时是否启用该设备

BOOTPROTO=none – > 手动(none/static)还是自动获取IP(dhcp)
在这里插入图片描述在这里插入图片描述

IPADDR=192.168.142.131 – > 手动输入(按照上述图片输入)
//根据自动获取的地址进行配置
用来定位主机

NETMASK=255.255.255.0
//子网掩码(手动输入)掩码分两部分 一部分是255 一部分是0
用来定义网络,这台主机是192.168.142的网络

GATEWAY=192.168.142.2
//网关,也叫默认路由(手动输入)
带你上网的路由器地址(VMware提供的地址)

DNS1=192.168.142.2
这个数字1不要忘了(手动输入)
域名解析。当你输入域名访问网站时,他告诉你IP地址。(负责记住IP地址)
根据截图配置

重启网络服务
[root@localhost ~]# systemctl restart network

查看IP地址
[root@localhost ~]# ip a 
主机名

改名方式1

查看主机名:

[root@localhost ~]# hostname --->查看
localhost.localdomain
[root@localhost ~]# hostname hang --->临时修改

配置主机名:
永久修改

[root@localhost ~]#hostnamectl   set-hostname   hanghang

退出shell即可生效

改名方式2
查看和配置主机名:

[root@localhost ~]# cat /etc/hostname
localhost.localdomain
[root@localhost ~]# vim /etc/hostname

重启生效

[root@localhost ~]# reboot
[root@localhost ~]# init 6
网络测试工具
测试工具
[root@qianfeng ~]# ip a		//查看所有IP(ifconfig)
[root@qianfeng ~]# ip route		//查看路由,查看网关( ip r)
[root@qianfeng ~]# ip neigh 	//(ip n)(了解)另一台主机ping通,查看邻居 和其他主机ping后 可用此命令查看
[root@qianfeng ~]# ping  127.0.0.1(代表ping本机,每个电脑的都一样

PING (Packet Internet Groper),因特网包探索器
两台虚拟机需要通信,vmnet号一定要相同
在这里插入图片描述

ports and services
安装示例服务
[root@aliyun ~]# yum -y install httpd 
[root@aliyun ~]# systemctl start httpd
[root@aliyun ~]# systemctl stop firewalld
端口号

是一段数字:0-65535
每一个服务程序,对应一到多个数字。
通过检查端口号,确认服务是否提供

Show TCP sockets

什么端口不重要 重要的是要知道端口的概念和查看的方法
ss:网络连接状态 t : tcp n :数字 l : 列出


```bash
[root@aliyun ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port 
LISTEN 0 128 *:80 *:*

[root@localhost ~]# ss -tna
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 :
LISTEN 0 128 *:22 :


  
 

#### 初始化服务器
##### 最小化安装
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/2020120521310952.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjgzNzc5Ng==,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205213112491.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjgzNzc5Ng==,size_16,color_FFFFFF,t_70)


##### 配置root密码

##### 配置IP地址(NAT)自动获取
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205213148136.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjgzNzc5Ng==,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205213157330.png)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205213200789.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjgzNzc5Ng==,size_16,color_FFFFFF,t_70)

##### 配置yum源
自动挂载光驱(没有网络的办法)
阿里YUM(企业的用法)

```bash
[root@localhost ~]# yum install -y wget

在这里插入图片描述

关闭防火墙和selinux
停止防火墙
[root@localhost ~]#	systemctl  stop firewalld (开机会重新打开)
开机禁用防火墙
[root@localhost ~]#	systemctl   disable   firewalld
查看防火墙状态
[root@localhost ~]#systemctl  status firewalld
	查看selinux
[root@localhost ~]#	getenforce
		enforcing 开启(会阻止你的程序)
		permissive 开启放行
		 disabled 禁用
临时关闭
[root@localhost ~]#	setenforce   0
		数字零,不是欧	
永久关闭  -- 重启生效
[root@localhost ~]# vi /etc/sysconfig/selinux 
SELINUX=disabled

在这里插入图片描述

安装常用程序并关机快照

上传下载工具 系统状态 字符浏览器 下载工具 网络工具 自动补全

[root@localhost ~]#yum install -y    lrzsz    sysstat  elinks   wget   net-tools   bash-completion  vim
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值