在 ubuntu 14.04 中的 p1p1 接口上添加静态 IP

在 ubuntu 14.04 中的 p1p1 接口上添加静态 IP

我想知道是否有人可以给我介绍一下当接口是 p1p1 等时 ubuntu 中的网络配置。我尝试过将 p1p1:0(如 eth0:0)用作辅助 IP,但没有成功。如果有人可以告诉我如何在 lo 和 p1p1 时修改 /etc/network/interfaces 以添加辅助 IP(使用相同的接口),我将不胜感激。

这是我所得到的(注释掉的行是失败的尝试,IP 被故意隐藏了):

# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto p1p1
iface p1p1 inet static
        address x.x.x.x
        netmask 255.255.255.248
        network x.x.x.x
        broadcast x.x.x.x
        gateway x.x.x.x
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search www.google.com

#secondary interface
#auto p2p1
#iface p2p1 inet static
#       address x.x.x.x
#       netmask x.x.x.x
#       network x.x.x.x
#       broadcast x.x.x.x
#       gateway x.x.x.x
#       dns-nameservers 8.8.8.8
#       dns-search www.google.com

#auto p3p1
#iface p3p1 inet static
#       address x.x.x.x
#       netmask 255.255.255.128
#       broadcast x.x.x.x
#       gateway x.x.x.x
#       DNS1=8.8.8.8
#       DNS2=8.8.4.4

如果有其他方法可以向服务器添加静态 IP,那么也可以。

谢谢!

答案1

其方式与使用 ethX 作为名称的方式相同。

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto p1p1
iface p1p1 inet static
        address x.x.x.x
        netmask 255.255.255.248
        network x.x.x.x
        broadcast x.x.x.x
        gateway x.x.x.x
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search www.google.com

iface p1p1:0 inet static
        address x.x.x.x
        netmask x.x.x.x
        broadcast x.x.x.x

iface p1p1:1 inet static
        address x.x.x.x
        netmask x.x.x.x
        broadcast x.x.x.x

如果愿意,您还可以将 p1p1 接口重命名为 eth0。

cd /etc/udev/rules.d
cp 70-persistent-net.rules 70-persistent-net.rules.bak
nano 70-persistent-net.rules

改变

NAME="p1p1" 

NAME="eth0"

相关内容