无法理解 ifup/ifdown 过程

无法理解 ifup/ifdown 过程

我正在尝试为设置虚拟 IP 。但配置后,当我尝试查看配置时,ucarp发生了一些奇怪的事情。我像这样更改ifup ifdown/etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 10.1.178.153
netmask 255.255.255.0
gateway 10.1.178.1
dns-nameservers 10.1.171.200

  #######################
  # ucarp configuration
  #######################
  # vid : The ID of the virtual server [1-255]
  ucarp-vid 1
  # vip : The virtual address
  ucarp-vip 10.1.178.150
  # password : A password used to encrypt Carp communications
  ucarp-password secret
  # advskew : Advertisement skew [1-255]
  ucarp-advskew 100
  # advbase : Interval in seconds that advertisements will occur
  ucarp-advbase 1
  # master : determine if this server is the master

# The carp network interface, on top of enp0s3
iface enp0s3:ucarp inet static
        address 10.1.178.150
        netmask 255.255.255.0
        gateway 10.1.178.1
        dns-nameservers 10.1.171.200

以下是此后终端程序的输出

$ sudo service networking restart
$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:c6:9b:54  
          inet addr:10.1.178.153  Bcast:10.1.178.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec6:9b54/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2826136 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1271544 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:320630219 (320.6 MB)  TX bytes:94783376 (94.7 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:37307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37307 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3039725 (3.0 MB)  TX bytes:3039725 (3.0 MB)

我尝试取enp0s3下来以便enp0s3:ucarp可以取上去,但是有一个惊喜#1

$ sudo ifdown enp0s3
RTNETLINK answers: No such process
$ ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:37358 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37358 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3042933 (3.0 MB)  TX bytes:3042933 (3.0 MB)

好吧,现在enp0s3我尝试提起的那个没有出现enp0s3:ucarp。但是出现了惊喜#2

$ sudo ifup enp0s3:ucarp
RTNETLINK answers: File exists
run-parts: /etc/network/if-up.d/avahi-autoipd exited with return code 2
Failed to bring up enp0s3:ucarp.
$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:c6:9b:54  
          inet6 addr: fe80::a00:27ff:fec6:9b54/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2826298 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1271688 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:320646091 (320.6 MB)  TX bytes:94802033 (94.8 MB)

enp0s3:ucarp Link encap:Ethernet  HWaddr 08:00:27:c6:9b:54  
          inet addr:10.1.178.150  Bcast:10.1.178.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:37376 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37376 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3044101 (3.0 MB)  TX bytes:3044101 (3.0 MB)

无法理解;无法配置ucarp;请求某人帮助我获得一些内心的平静!!

  • 是否ifconfig显示活动网络配置/所有网络配置,无论启动/关闭?
  • 如何建立虚拟地址导致主接口也启动?

答案1

/run/network/ifstate没关系,Ubuntu 15.10 的更新似乎已经解决了这个问题。此外,还学会了交叉验证每个操作。

相关内容