Linux cenos7 modify ip (temporary and permanent)

1. Temporarily modify ip

ifconfig network card name ip address-directly modify the network card ip, restarting will fail

//设置ip
 [root@localhost ~]# ifconfig ens33 192.168.43.137
//重启网络
 [root@localhost ~]# systemctl restart network

Insert picture description here
Insert picture description here

2. Add multiple temporary ip

ifconfig network card name: 0 first IP address (netmask subnet mask)-add an IP, the default subnet mask is 255.255.255.0
config network card name: 1 second IP address (netmask subnet mask)-add one IP

//给网卡添加多个ip
[root@localhost ~]# ifconfig ens33:0 192.168.43.11 up
[root@localhost ~]# ifconfig ens33:1 192.168.43.12 up
//重启后失效
 [root@localhost ~]# systemctl restart network

Add multiple temporary ips
Insert picture description here
delete temporary ips
Insert picture description here

3. Permanently modify ip (use nmtui text box to modify ip

[root@localhost ~]# nmtui

Always return and then save and exit, it will take effect after restart

3. Permanently modify the ip (modify the configuration file to modify the ip)

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
//打开后注意的地方
BOOTPROTO=none         #等号后面写:dhcp表示动态获取ip地址,statis表示静态ip,none表示不指定,就是静态
ONBOOT=yes			# 在系统引导是是否激活此设备

vim shortcut keys:

i: Enter insert mode
Save: press eSc first, then input: Wq
Insert picture description here

One thing to note, after configuring the ip, if you can’t access the external network, then modify it as follows
[root@localhost network-scripts]# vi /etc/resolv.conf 

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44797182/article/details/110917379
Recommended