如何在 Linux 中永久创建环回接口

如何在 Linux 中永久创建环回接口

我的目标是创建 2 个环回接口并将它们永久保存在EC2 实例基于 AWS Linux Ubuntu。我在/ect/network/interfaces

auto lo lo:1 lo:2
iface lo inet loopback

iface lo:1 inet static
        address 127.0.0.1
        netmask 255.255.255.240
        network 127.0.0.0

iface lo:2 inet static
        address 127.0.0.2
        netmask 255.255.255.240
        network 127.0.0.0

当我重新启动机器时,我ifconfig只得到了安装操作系统时已配置的接口,什么也没有得到。

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.2.1.10  netmask 255.255.255.240  broadcast 172.2.1.15
        inet6 2600:1f14:8df:c16:b320:cc3f:ad7a:e26  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::843:d4ff:feb2:a872  prefixlen 64  scopeid 0x20<link>
        ether 0a:43:d4:b2:a8:72  txqueuelen 1000  (Ethernet)
        RX packets 503  bytes 61839 (61.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 545  bytes 74423 (74.4 KB)
        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 124  bytes 9720 (9.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 124  bytes 9720 (9.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

我设法找到了解决方案。事实证明,Ubuntu Server 18 有一些其他配置可用于此类目的。我决定使用版本 16,并且配置有效。

相关内容