如何在Centos中创建属于不同子网的永久IP别名

如何在Centos中创建属于不同子网的永久IP别名

我跟着链接并在我的 centos 6.5 机器上创建了几个别名 ip,但所有这些 ip 都属于同一子网。

我拥有的:

我的机器:eth0,10.91.56.3
IP别名1:eth0:1,10.91.56.4
IP别名1:eth0:2,10.91.56.5
IP别名1:eth0:3,10.91.56.6
IP别名1:eth0:4,10.91.56.7

现在我想在我的机器上创建更多的别名 IP,但属于不同的子网。

我想要的是:

我的机器:eth0、10.91.56.3
IP Alias1:eth0:1、10.91.56.4
IP Alias1:eth0:2、10.91.56.5
IP Alias1:eth0:3、10.91.56.6
IP Alias1:eth0:4、10.91.56.7
IP Alias1 :eth0:5, 10.91.57.4
IP 别名 1:eth0:6, 10.91.58.5
IP 别名 1:eth0:7, 10.91.59.6
IP 别名 1:eth0:8, 10.91.60.7

输出ip addr show dev eth0

[root@PythonClient Desktop]# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:2b:b7:de brd ff:ff:ff:ff:ff:ff
    inet 10.91.56.3/24 brd 10.91.56.255 scope global eth0
    inet 10.91.56.4/24 brd 10.91.56.255 scope global secondary eth0:1
    inet 10.91.56.13/24 brd 10.91.56.255 scope global secondary eth0:10
    inet 10.91.56.14/24 brd 10.91.56.255 scope global secondary eth0:11
    inet 10.91.56.15/24 brd 10.91.56.255 scope global secondary eth0:12
    inet 10.91.56.16/24 brd 10.91.56.255 scope global secondary eth0:13
    inet 10.91.56.17/24 brd 10.91.56.255 scope global secondary eth0:14
    inet 10.91.56.18/24 brd 10.91.56.255 scope global secondary eth0:15
    inet 10.91.56.19/24 brd 10.91.56.255 scope global secondary eth0:16
    inet 10.91.56.20/24 brd 10.91.56.255 scope global secondary eth0:17
    inet 10.91.56.21/24 brd 10.91.56.255 scope global secondary eth0:18
    inet 10.91.56.22/24 brd 10.91.56.255 scope global secondary eth0:19
    inet 10.91.56.5/24 brd 10.91.56.255 scope global secondary eth0:2
    inet 10.91.56.23/24 brd 10.91.56.255 scope global secondary eth0:20
    inet 10.91.56.24/24 brd 10.91.56.255 scope global secondary eth0:21
    inet 10.91.56.25/24 brd 10.91.56.255 scope global secondary eth0:22
    inet 10.91.56.26/24 brd 10.91.56.255 scope global secondary eth0:23
    inet 10.91.56.27/24 brd 10.91.56.255 scope global secondary eth0:24
    inet 10.91.56.28/24 brd 10.91.56.255 scope global secondary eth0:25
    inet 10.91.56.29/24 brd 10.91.56.255 scope global secondary eth0:26
    inet 10.91.56.30/24 brd 10.91.56.255 scope global secondary eth0:27
    inet 10.91.56.31/24 brd 10.91.56.255 scope global secondary eth0:28
    inet 10.91.56.32/24 brd 10.91.56.255 scope global secondary eth0:29
    inet 10.91.56.6/24 brd 10.91.56.255 scope global secondary eth0:3
    inet 10.91.56.33/24 brd 10.91.56.255 scope global secondary eth0:30
    inet 10.91.56.34/24 brd 10.91.56.255 scope global secondary eth0:31
    inet 10.91.56.35/24 brd 10.91.56.255 scope global secondary eth0:32
    inet 10.91.56.36/24 brd 10.91.56.255 scope global secondary eth0:33
    inet 10.91.56.37/24 brd 10.91.56.255 scope global secondary eth0:34
    inet 10.91.56.38/24 brd 10.91.56.255 scope global secondary eth0:35
    inet 10.91.56.39/24 brd 10.91.56.255 scope global secondary eth0:36
    inet 10.91.56.40/24 brd 10.91.56.255 scope global secondary eth0:37
    inet 10.91.56.41/24 brd 10.91.56.255 scope global secondary eth0:38
    inet 10.91.56.42/24 brd 10.91.56.255 scope global secondary eth0:39
    inet 10.91.56.7/24 brd 10.91.56.255 scope global secondary eth0:4
    inet 10.91.56.43/24 brd 10.91.56.255 scope global secondary eth0:40
    inet 10.91.56.44/24 brd 10.91.56.255 scope global secondary eth0:41
    inet 10.91.56.45/24 brd 10.91.56.255 scope global secondary eth0:42
    inet 10.91.56.46/24 brd 10.91.56.255 scope global secondary eth0:43
    inet 10.91.56.47/24 brd 10.91.56.255 scope global secondary eth0:44
    inet 10.91.56.48/24 brd 10.91.56.255 scope global secondary eth0:45
    inet 10.91.56.49/24 brd 10.91.56.255 scope global secondary eth0:46
    inet 10.91.56.50/24 brd 10.91.56.255 scope global secondary eth0:47
    inet 10.91.56.51/24 brd 10.91.56.255 scope global secondary eth0:48
    inet 10.91.56.52/24 brd 10.91.56.255 scope global secondary eth0:49
    inet 10.91.56.8/24 brd 10.91.56.255 scope global secondary eth0:5
    inet 10.91.56.53/24 brd 10.91.56.255 scope global secondary eth0:50
    inet 10.91.56.9/24 brd 10.91.56.255 scope global secondary eth0:6
    inet 10.91.56.10/24 brd 10.91.56.255 scope global secondary eth0:7
    inet 10.91.56.11/24 brd 10.91.56.255 scope global secondary eth0:8
    inet 10.91.56.12/24 brd 10.91.56.255 scope global secondary eth0:9
    inet6 fe80::20c:29ff:fe2b:b7de/64 scope link 
       valid_lft forever preferred_lft forever

我该如何实现这一目标?

答案1

您正在使用的 IP 地址保留IP地址范围可容纳约 1600 万个地址。您可以将掩码设置为 255.0.0.0 或 255.255.0.0,如果您希望子网上有更多客户端,则不必将其限制为 255.255.255.0。

这不会影响您的网关是什么,但由于该网关不在 10.91.56.*/24 的范围内,因此您应该确保了解如何到达该网关,以及您添加的任何地址是否与10.91.57.* 范围内的其他内容。

相关内容