网资酷

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 120|回复: 1

Rocky Linux-0103-教程-网络-网络配置-01

[复制链接]

2

主题

5

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2022-12-10 05:52:03 | 显示全部楼层 |阅读模式
0、背景

CentOS 8 已停止维护,Rocky Linux 是未来~
从本篇起翻译一下 Rocky Linux 网络~
(1)本系列文章

格瑞图:Rocky Linux-0001~0011-教程-自定义内核
格瑞图:Rocky Linux-0012~0024-教程-共同构建文档
格瑞图:Rocky Linux-0025~0034-教程-自动化
格瑞图:Rocky Linux-0034~0043-教程-文件同步
格瑞图:Rocky Linux-0044~0051-教程-内容管理
格瑞图:Rocky Linux-0053~0053-教程-通信服务
格瑞图:Rocky Linux-0054~0082-教程-容器技术
格瑞图:Rocky Linux-0083-0084-教程-数据库
格瑞图:Rocky Linux-0085-0090-教程-域名解析服务
格瑞图:Rocky Linux-0091-0100-教程-文件共享服务
格瑞图:Rocky Linux-0101-0102-教程-镜像管理
1、网络配置 - Network Configuration

(1)简介 - Introduction¶

You can't do much with a computer these days without network connectivity. Whether you need to update the packages on a server or simply browse external websites from your laptop, you will need network access! This guide aims to provide Rocky Linux users the basic knowledge on setting up network connectivity.
没有网络连接的情况下,使用计算机并不能做太多的事情。无论是更新服务器上的软件包,还是从笔记本上浏览一下外部歪脖站点,需要网络访问。本教程目标是为洛基林纽克斯用户提供设置网络连接基础的知识。
(2)前置条件 - Prerequisites¶

A certain amount of comfort operating from the command line
从命令行操作的舒适度。
Elevated or administrative privileges on the system (For example root, sudo and so on)
提权或系统管理员权限(例如:根用户、速度等等)。
Optional: familiarity with networking concepts
可选:熟悉网络概念。
2、网络配置基于洛基林纽克斯九 - Network Configuration - Rocky Linux 9.0¶

A lot has changed with network configuration as of Rocky Linux 9.0. One of the major changes is the move from Network-Scripts (still available to install-but effectively deprecated) to the use of Network Manager and key files, rather than ifcfg based files. NetworkManager as of 9.0, prioritizes keyfiles over the previous ifcfg files. Since this is now the default, the act of configuring the network should now take the default as the proper way of doing things, given that other changes over the years have meant the eventual deprecation and removal of older utilities. This guide will attempt to walk you through the use of Network Manager and the latest changes within Rocky Linux 9.0.
在洛基林纽克斯九上关于网络的配置很多发生了变化。一个主要的变化是将网络脚本的使用改为网络管理器的使用以及一些关键文件,不在基于 ic。九点零上的 nm 优先使用 kf 而不是 ic 文件。因为现在这已经成为默认,配置网络时应该选择默认的方式才是正确的做事方式,这些年来其他的方式将会弃用,并删除旧的工具。该教程尝试介绍使用 nm,并介绍洛基林纽克斯九点零的最新变更。
(1)前置条件 - Prerequisites¶

A certain amount of comfort operating from the command line
从命令行操作的舒适性。
Elevated or administrative privileges on the system (For example root, sudo and so on)
提权或系统管理员权限(例如:根用户、速度等等)。
Optional: familiarity with networking concepts
可选:熟悉网络概念。
(2)使用网络管理器服务 - Using NetworkManager service¶

At the user level, the networking stack is managed by NetworkManager. This tool runs as a service, and you can check its state with the following command:
从使用者角度,网络栈由网络管理器 nm 管理。该工具作为服务运行,可以使用下面的命令检查其状态:
systemctl status NetworkManager(3)配置文件 - Configuration files¶

As noted at the beginning, the configuration files by default are now key files. You can see how NetworkManager prioritizes these files by running the following command:
正如开篇所言,配置文件现在默认是键值文件 kf。通过使用网络管理器 nm 运行下面的命令来查看文件优先级:
NetworkManager --print-config
This gives you output that looks like this:
输出如下所示:
[main]
# plugins=keyfile,ifcfg-rh
# rc-manager=auto
# auth-polkit=true
# iwd-config-path=
dhcp=dhclient
configure-and-quit=no

[logging]
# backend=journal
# audit=false

[device]
# wifi.backend=wpa_supplicant

# no-auto-default file "/var/lib/NetworkManager/no-auto-default.state"
Note at the top of the configuration file the reference to keyfile followed by ifcfg-rh. This means that keyfile is the default. Any time you run any of the NetworkManager tools to configure an interface (example: nmcli or nmtui), it will automatically build or update key files.
注意配置文件的顶部首先引用了 kf 然后是 ic-r。这意味着 kf 是默认。任何时间都可以运行 nm 工具来配置网卡(例如: nc 或 nt),他会自动构建或者更新 kf。
Configuration Storage Location
In Rocky Linux 8.6, the storage location for network configuration was in /etc/sysconfig/Network-Scripts/. With Rocky Linux 9.0, the new default storage location for the key files is in /etc/NetworkManager/system-connections.
配置存储路径
在洛基林纽克斯八点六上,网络配置文件存储路径是 /e/s/n-s。在洛基林纽克斯九点零上,默认存储 kf 文件的路径是 /e/nm/s-c。
The primary (but not the only) utility used for configuring a network interface is the nmtui command. This can also be done with the nmcli command, but is much less intuitive. We can show the interface as it is currently configured using nmcli with:
主要(但不是唯一的)配置网络接口的工具是 nt 命令。也可以通过 nc 命令完成,但是其并不直观。可以使用 nc 命令展示接口当前的配置:
nmcli device show enp0s3
GENERAL.DEVICE:                         enp0s3
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         08:00:27:BA:CE:88
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     enp0s3
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.1.151/24
IP4.GATEWAY:                            192.168.1.1
IP4.ROUTE[1]:                           dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 100
IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             8.8.4.4
IP4.DNS[3]:                             192.168.1.1
IP6.ADDRESS[1]:                         fe80::a00:27ff:feba:ce88/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 1024
Tips:
There are a few ways or mechanisms by which systems can be assigned their IP configuration information. The two most common methods are - Static IP configuration scheme and Dynamic IP configuration scheme.
The static IP configuration scheme is very popular on server class systems or networks.
The dynamic IP approach is popular on home and office networks or workstation and desktop class systems in a business environment. The dynamic scheme usually needs something extra that is locally available and that can supply proper IP configuration information to requesting workstations and desktops. This something is called the Dynamic Host Configuration Protocol (DHCP). On a home network, and even on most business networks, this service is provided by a DHCP Server configured for the purpose. This can be a separate server or part of a router configuration.
提示:
有一些方法或者机制,通过其可以设置爱啤配置信息。两个最常见的方式是:静态爱啤地址配置和动态爱啤地址配置。
静态爱啤地址配置流行于服务器或者网络环境。
动态爱啤地址配置在家庭或者办公网络,适用于商业环境中的工作站和台式机。动态模式通常需要一些额外的硬件,可以通过本地访问提供合适的爱啤配置信息给请求的工作站或者台式机。这就是动态地址分配协议 DHCP。在家庭网络中,甚至大多数商业网络,这个服务有一个动态地址分配协议服务器配置并提供。这可以是一个单独的服务器或者是路由器配置的一部分。
N、后记



Badlands National Park in the United States
米国荒地国家公园
~
回复

使用道具 举报

1

主题

8

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2025-5-5 18:41:35 | 显示全部楼层
鼎力支持!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|网资酷

GMT+8, 2025-7-9 07:09 , Processed in 0.085544 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表