centos7网卡填加多个临时IP

centos7网卡填加多个临时IP

查看当前IP:

[root@fake ~]# 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:

[root@fake ~]# ifconfig ens33:1 192.168.115.130 broadcast 192.168.115.255 netmask 255.255.255.0 up
[root@fake ~]# route add -host 192.168.115.130 dev ens33:1
[root@fake ~]# ifconfig ens33:2 192.168.115.131 broadcast 192.168.115.255 netmask 255.255.255.0 up  
[root@fake ~]# route add -host 192.168.115.131 dev ens33:2

再次查看IP:

[root@fake ~]# 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


[root@fake ~]# ifconfig ens33:1 down
[root@fake ~]# ifconfig ens33:2 down
[root@fake ~]# 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

猜你喜欢

转载自blog.csdn.net/u013887008/article/details/83791096
今日推荐