临时生效方式
[root@bogon network-scripts]# ifconfig ens192:0 192.168.21.130 netmask 255.255.255.0 up [root@bogon network-scripts]# ifconfig ens192:1 192.168.21.131 netmask 255.255.255.0 up [root@bogon network-scripts]# ifconfig ens192:2 192.168.21.132 netmask 255.255.255.0 up [root@bogon network-scripts]# ifconfig ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.52 netmask 255.255.255.0 broadcast 192.168.21.255 inet6 fe80::2725:4338:4578:954c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) RX packets 7772 bytes 748880 (731.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2136 bytes 959641 (937.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens192:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.130 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) ens192:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.131 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) ens192:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.132 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 16 bytes 1376 (1.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1376 (1.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
重启网络,临时添加的ip就会失效。
[root@bogon network-scripts]# systemctl restart network.service [root@bogon network-scripts]# ifconfig ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.52 netmask 255.255.255.0 broadcast 192.168.21.255 inet6 fe80::2725:4338:4578:954c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) RX packets 7772 bytes 748880 (731.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2136 bytes 959641 (937.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 16 bytes 1376 (1.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1376 (1.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
配置文件方式
[root@bogon network-scripts]# cat ifcfg-ens192:0 TYPE=Ethernet BOOTPROTO=static NAME=ens192:0 DEVICE=ens192:0 ONBOOT=yes IPADDR=192.168.21.130 NETMASK=255.255.255.0 [root@bogon network-scripts]# cat ifcfg-ens192:1 TYPE=Ethernet BOOTPROTO=static NAME=ens192:1 DEVICE=ens192:1 ONBOOT=yes IPADDR=192.168.21.131 NETMASK=255.255.255.0 [root@bogon network-scripts]# cat ifcfg-ens192:2 TYPE=Ethernet BOOTPROTO=static NAME=ens192:2 DEVICE=ens192:2 ONBOOT=yes IPADDR=192.168.21.132 NETMASK=255.255.255.0
重启网络生效
[root@bogon network-scripts]# systemctl restart network.service [root@bogon network-scripts]# ifconfig ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.52 netmask 255.255.255.0 broadcast 192.168.21.255 inet6 fe80::2725:4338:4578:954c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) RX packets 7772 bytes 748880 (731.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2136 bytes 959641 (937.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens192:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.130 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) ens192:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.131 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) ens192:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.21.132 netmask 255.255.255.0 broadcast 192.168.21.255 ether 00:0c:29:2a:91:5e txqueuelen 1000 (Ethernet) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 16 bytes 1376 (1.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1376 (1.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- 本文固定链接: https://www.laofuxi.com/1118.html
- 转载请注明: 劳福喜 于 劳福喜-专注Linux服务器运维技术 发表