在linux中更改ip地址的三种方式
文章目录
第一种在linux的网卡配置中更改IP地址
这里是redhat9的版本,网卡配置改变了位置需要改变,在文本中查找
[root@zcj ~]# cd /etc/sysconfig/network-scripts/[root@zcj network-scripts]# ls
readme-ifcfg-rh.txt
[root@zcj network-scripts]# cat readme-ifcfg-rh.txt
NetworkManager stores new network profiles in keyfile formatin the
/etc/NetworkManager/system-connections/ directory. //网卡配置的位置
Previously, NetworkManager stored network profiles in ifcfg formatin this directory (/etc/sysconfig/network-scripts/). However, the ifcfg
format is deprecated. By default, NetworkManager no longer creates
new profiles in this format.
[root@zcj network-scripts]# cd /etc/NetworkManager/system-connections/[root@zcj system-connections]# ls
ens160.nmconnection
[root@zcj system-connections]# vim ens160.nmconnectionformat and stores them in /etc/NetworkManager/system-connections/.
Alternatively, to migrate only a specific profile, enter:
# nmcli connection migrate <profile_name|UUID|D-Bus_path>
For further details, see:
* nm-settings-keyfile(5)
* nmcli(1)[root@zcj network-scripts]# cd /etc/NetworkManager/system-connections/[root@zcj system-connections]# ls
ens160.nmconnection
[root@zcj system-connections]# vim ens160.nmconnection [root@zcj system-connections]# cat ens160.nmconnection .....
[ipv4]address1=192.168.100.141/24,192.168.100.2 //配置的IP地/子网掩码/网关配置
dns=8.8.8.8; //域名配置
method=manual //获取的方式,我这里是手动自己配置
....[proxy]
第二种通过万能的nmcil命令
[root@zcj ~]# nmcli connection show /查看接口的连接
NAME UUID TYPE DEVICE
ens160 37290f79-1905-3a59-9f1c-ff08ef42bd44 ethernet ens160
lo 4444c881-ceef-4a42-9778-0aca163acfcf loopback lo
[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
nm nm-connection-editor nmtui nmtui-edit
nmcli nm-online nmtui-connect nmtui-hostname
[root@zcj ~]# nmcli connection up ens160 //重新连接网络
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
第三种图形交互模式更改IP地址
[root@zcj ~]# nmtui //进入图形的交互命令
点击回车进入配置
用tab来切换选项,在编辑这个选项点击进入
本文转载自: https://blog.csdn.net/2401_83562494/article/details/143417028
版权归原作者 孤枫21 所有, 如有侵权,请联系我们删除。
版权归原作者 孤枫21 所有, 如有侵权,请联系我们删除。