0


linux更改配置的三种方式

在linux中更改ip地址的三种方式

文章目录

第一种在linux的网卡配置中更改IP地址

这里是redhat9的版本,网卡配置改变了位置需要改变,在文本中查找

  1. [root@zcj ~]# cd /etc/sysconfig/network-scripts/[root@zcj network-scripts]# ls
  2. readme-ifcfg-rh.txt
  3. [root@zcj network-scripts]# cat readme-ifcfg-rh.txt
  4. NetworkManager stores new network profiles in keyfile formatin the
  5. /etc/NetworkManager/system-connections/ directory. //网卡配置的位置
  6. Previously, NetworkManager stored network profiles in ifcfg formatin this directory (/etc/sysconfig/network-scripts/). However, the ifcfg
  7. format is deprecated. By default, NetworkManager no longer creates
  8. new profiles in this format.
  9. [root@zcj network-scripts]# cd /etc/NetworkManager/system-connections/[root@zcj system-connections]# ls
  10. ens160.nmconnection
  11. [root@zcj system-connections]# vim ens160.nmconnectionformat and stores them in /etc/NetworkManager/system-connections/.
  12. Alternatively, to migrate only a specific profile, enter:
  13. # nmcli connection migrate <profile_name|UUID|D-Bus_path>
  14. For further details, see:
  15. * nm-settings-keyfile(5)
  16. * nmcli(1)[root@zcj network-scripts]# cd /etc/NetworkManager/system-connections/[root@zcj system-connections]# ls
  17. ens160.nmconnection
  18. [root@zcj system-connections]# vim ens160.nmconnection [root@zcj system-connections]# cat ens160.nmconnection .....
  19. [ipv4]address1=192.168.100.141/24,192.168.100.2 //配置的IP地/子网掩码/网关配置
  20. dns=8.8.8.8; //域名配置
  21. method=manual //获取的方式,我这里是手动自己配置
  22. ....[proxy]

第二种通过万能的nmcil命令

  1. [root@zcj ~]# nmcli connection show /查看接口的连接
  2. NAME UUID TYPE DEVICE
  3. ens160 37290f79-1905-3a59-9f1c-ff08ef42bd44 ethernet ens160
  4. lo 4444c881-ceef-4a42-9778-0aca163acfcf loopback lo
  5. [root@zcj ~]# nmcli connection modify ens160 ipv4.address 192.168.100.141/24 ipv4.method manual ipv4.gateway 192.168.100.2 ipv4.dns 8.8.8.8 autoconnect yes //配置address(网络地址和掩码) method(IP地址的获取方式) geteway(网关配置) dns(域名的配置)[root@zcj ~]# nmcli connection reload //重新加载接口配置[root@zcj ~]# nm
  6. nm nm-connection-editor nmtui nmtui-edit
  7. nmcli nm-online nmtui-connect nmtui-hostname
  8. [root@zcj ~]# nmcli connection up ens160 //重新连接网络
  9. 连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3

第三种图形交互模式更改IP地址

  1. [root@zcj ~]# nmtui //进入图形的交互命令

在这里插入图片描述

点击回车进入配置

在这里插入图片描述

用tab来切换选项,在编辑这个选项点击进入

在这里插入图片描述

标签: linux 运维 服务器

本文转载自: https://blog.csdn.net/2401_83562494/article/details/143417028
版权归原作者 孤枫21 所有, 如有侵权,请联系我们删除。

“linux更改配置的三种方式”的评论:

还没有评论