centos7網絡卡填加多個臨時IP
阿新 • • 發佈:2018-12-26
centos7網絡卡填加多個臨時IP
檢視當前IP:
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.115.129 netmask 255.255.255.0 broadcast 192.168.115.255
inet6 fe80::670c:ed0c:a751:2c6b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a8:58:e6 txqueuelen 1000 ( Ethernet)
RX packets 28045 bytes 4442641 (4.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28009 bytes 5788907 (5.5 MiB)
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 1 (Local Loopback)
RX packets 55977 bytes 9554164 (9.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55977 bytes 9554164 (9.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
在同一網絡卡上填加多個臨時IP:
[[email protected] ~]# ifconfig ens33:1 192.168.115.130 broadcast 192.168.115.255 netmask 255.255.255.0 up
[[email protected] ~]# route add -host 192.168.115.130 dev ens33:1
[[email protected] ~]# ifconfig ens33:2 192.168.115.131 broadcast 192.168.115.255 netmask 255.255.255.0 up
[[email protected] ~]# route add -host 192.168.115.131 dev ens33:2
再次檢視IP:
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.115.129 netmask 255.255.255.0 broadcast 192.168.115.255
inet6 fe80::670c:ed0c:a751:2c6b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a8:58:e6 txqueuelen 1000 (Ethernet)
RX packets 28103 bytes 4448066 (4.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28032 bytes 5793483 (5.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.115.130 netmask 255.255.255.0 broadcast 192.168.115.255
ether 00:0c:29:a8:58:e6 txqueuelen 1000 (Ethernet)
ens33:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.115.131 netmask 255.255.255.0 broadcast 192.168.115.255
ether 00:0c:29:a8:58:e6 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 1 (Local Loopback)
RX packets 55977 bytes 9554164 (9.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55977 bytes 9554164 (9.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
看是否可以ping通:
C:\Users\xxx>ping 192.168.115.130
正在 Ping 192.168.115.130 具有 32 位元組的資料:
來自 192.168.115.130 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.130 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.130 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.130 的回覆: 位元組=32 時間<1ms TTL=64
192.168.115.130 的 Ping 統計資訊:
資料包: 已傳送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計時間(以毫秒為單位):
最短 = 0ms,最長 = 0ms,平均 = 0ms
C:\Users\xxx>ping 192.168.115.131
正在 Ping 192.168.115.131 具有 32 位元組的資料:
來自 192.168.115.131 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.131 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.131 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.115.131 的回覆: 位元組=32 時間<1ms TTL=64
192.168.115.131 的 Ping 統計資訊:
資料包: 已傳送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計時間(以毫秒為單位):
最短 = 0ms,最長 = 0ms,平均 = 0ms
關閉臨時IP
[[email protected] ~]# ifconfig ens33:1 down
[[email protected] ~]# ifconfig ens33:2 down
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.115.129 netmask 255.255.255.0 broadcast 192.168.115.255
inet6 fe80::670c:ed0c:a751:2c6b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a8:58:e6 txqueuelen 1000 (Ethernet)
RX packets 28227 bytes 4459398 (4.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28089 bytes 5802489 (5.5 MiB)
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 1 (Local Loopback)
RX packets 55977 bytes 9554164 (9.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55977 bytes 9554164 (9.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0