我正在嘗試設定虛擬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
沒關係,Ubuntu 15.10 的更新似乎已經解決了這個問題。此外,/run/network/ifstate
也學會了交叉驗證每項操作。