很多教程都展示如何使用 ifconfig 设置 carp: https://www.netbsd.org/docs/guide/en/chap-carp.html
我想知道是否可以使用 /etc/network/interfaces 执行相同操作?
例如,我该如何复制这个:
# ifconfig carp0 create
# ifconfig carp0 vhid 1 pass lanpasswd \
carpdev em0 advskew 100 10.0.0.1 255.255.255.0
在 /etc/network/interfaces 中?
谢谢!!
答案1
尝试使用带有预启动和启动选项的手动界面。我会从以下操作开始:
auto carp0
iface carp0 manual
pre-up ifconfig carp0 create | true
up ifconfig carp0 vhid1 pass lanpasswd carpdev em0 advskew 100 10.0.0.1 255.255.255.0
down ifconfig carp0 down
该命令man interfaces
应该为您提供有关如何使用的文档/etc/network/interfaces
。
答案2
是的,这是可能的。以下是 /etc/network/interfaces 的示例配置:
# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.5.2
netmask 255.255.254.0
gateway 192.168.5.1
dns-nameservers 192.168.5.1
#######################
# ucarp configuration
#######################
# vid : The ID of the virtual server [1-255]
ucarp-vid 1
# vip : The virtual address
ucarp-vip 192.168.5.3
# password : A password used to encrypt Carp communications
ucarp-password secret
# advskew : Advertisement skew [1-255]
ucarp-advskew 1
# advbase : Interval in seconds that advertisements will occur
ucarp-advbase 1
# master : determine if this server is the master
ucarp-master no
# The carp network interface, on top of eth0
iface eth1:ucarp inet static
address 192.168.5.3
netmask 255.255.255.0
干杯