重新点亮linux 命令树————网络管理和网络配置文件[十一六]

前言

简单整理一下网络管理和网络配置文件。

正文

网络服务程序分为两种:分别是SysV和systemd

  1. service network start|stop|restart

  2. chkconfig --list network

chkconfig --level 2345 network off 关闭network 2345的功能

systemctl disable NetworkManager 禁用NetworkManager

  1. systemctl list-unit-files NetworkManager.service 查看NetworkManager服务

  2. systemctl start|stop|restart networkManager 停止和使用networkManager 服务

  3. systemctl enable|disable networkManager 是否禁用networkManager服务

网络配置文件是:

  1. ifcfg-eth0

  2. /etc/hosts

查看一下网络状态:service network status

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

chkconfig --list network

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

systemctl list-unit-files NetworkManager.service

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

一般来说network和NetworkManager 是配置冲突的,那么一般不用NetworkManager,因为里面水深。

后面几个命令可以自己试一下。

那么就来看下配置文件吧。

这里ifcfg-eth0 在centos 是在/etc/sysconfig/network-scripts/下。

而在ubuntu系列是在/etc/systemd/resolved.conf

那么现在就来看一下吧。

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

BOOTPROTO=dhcp 表示dhcp 分配方式。

ONBOOT=yes 开机网卡是否被使用

下面介绍一下静态配置:

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

然后怎么让其马上生效呢?service network restart.或者systemctl restart NetworkManager.service

那么如何修改hostname呢?

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

这样是查看。

如果是临时生效,可以使用hostname c7.testxxx这样就是临时生效。

永久生效可以使用 hostnamectl sethostname c7.testxxx.

也需要在/etc/hosts添加:

127.0.0.1 c7.testxxx 

因为很多服务依赖主机名,如果主机名修改可能会导致一些服务不可用。

linux 命令树

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

下一节 软件管理包。

重新点亮linux 命令树————网络管理和网络配置文件[十一六]

上一篇:如何检查你机器上是否有安装Windows 11所需要的TPM


下一篇:Linux的链接(入门)