Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having trouble configuring carp interfaces in FreeBSD 10-RELEASE.

The following configuration works.

#/boot/loader.conf
carp_load="YES"


#/etc/rc.conf
ifconfig_em1="inet 192.168.1.10 netmask 255.255.255.0"
ifconfig_em2="inet 192.168.2.10 netmask 255.255.255.0"

ifconfig_em1_alias0="vhid 11 advskew 210 pass PASSWORD 192.168.1.11/32"
ifconfig_em1_alias1="vhid 12 advskew 210 pass PASSWORD 192.168.1.12/32"
ifconfig_em1_alias2="vhid 13 advskew 210 pass PASSWORD 192.168.1.13/32"

ifconfig_em2_alias0="vhid 20 advskew 210 pass PASSWORD 192.168.2.20/32"
ifconfig_em2_alias1="vhid 21 advskew 210 pass PASSWORD 192.168.2.21/32"
ifconfig_em2_alias2="vhid 22 advskew 210 pass PASSWORD 192.168.2.22/32"

I am having trouble with the alias's.

It seems each alias per interface must be numbered starting with 0. It also seems each alias number must be sequential, skipping numbers will result in the interface not being created.

For example if I comment out ifconfig_em1_alias0 all the rest will fail.

Does anyone know if this is the intended implementation?

share|improve this question
    
1. What does this have to do with CARP? 2. Those are invalid netmasks 3. You can't have the same IP on multiple interfaces on the same machine. 4. The alias0..n behavior you describe is normal and has worked that way for a decade or more. –  Chris S Feb 13 at 3:01
1  
CARP has been rewritten in freebsd-10. Having to change all my ifconfing_carp<n> properties to aliases is what inspired this question. In freeBSD < 10 carp was defined as a cloned interfase and the order didn't matter. Never dealing with more than a couple of alias I was unaware of the requirement of sequential numbering. I have since answered my own question. I have opted to use ifconfig_<interface>_aliases making it easier to add and remove carp interfaces. –  Aaron Renoir Feb 13 at 20:19
    
When configuring cloned interfaces you explicitly named what interfaces you wanted configured, so the numbering didn't matter. In any of the auto-configured interface instances, like aliases, it has always been the case that you must start at 0 and number sequentially. None of this is new in 10.0 and none of it has anything to do with CARP itself. –  Chris S Feb 13 at 20:52
    
Yes that is true the ifconfig_<interface>_alias<n> rc.conf property functionality has not changed. I only noticed this behavior after converting a lot of carp addresses to aliases. So yes, it has nothing to do with carp itself. However I feel the question is valid because I and maybe others ran into this "difficult to manage behavior" when updating carp interfaces to this new syntax. –  Aaron Renoir Feb 13 at 21:56
    
I'll agree to disagree. Also, the scripts that read this configuration are in /etc/network.subr in case you need additional insight into how this works. –  Chris S Feb 14 at 3:11
add comment

2 Answers

Firstly, if you are assigning multiple addresses in the same subnet to the same interface, the secondary addresses should have the subnet mask /32 and be prefixed with the word alias:

ifconfig_em1="inet 38.111.159.78 netmask 192.168.1.10" ifconfig_em2="inet 38.111.159.78 netmask 192.168.2.10"

ifconfig_em1_alias0="vhid 11 advskew 210 pass PASSWORD alias 192.168.1.11/32" ifconfig_em1_alias1="vhid 12 advskew 210 pass PASSWORD alias 192.168.1.12/32" ifconfig_em1_alias2="vhid 13 advskew 210 pass PASSWORD alias 192.168.1.13/32"

ifconfig_em2_alias0="vhid 20 advskew 210 pass PASSWORD alias 192.168.2.20/32" ifconfig_em2_alias1="vhid 21 advskew 210 pass PASSWORD alias 192.168.2.21/32" ifconfig_em2_alias2="vhid 22 advskew 210 pass PASSWORD alias 192.168.2.22/32"

Note: in a general configuration, where you just want to bind IP addresses and skip the _alias0 _alias1 stuff, you can use:

ipv4_addrs_em1="192.168.2.20-22/24"

But this doesn't work when you need to indicate a vhid for each IP address.

share|improve this answer
    
whoops the /24 was a typo they are on the same subnet. I have to indicate a vhid for each address according to the new carp manual. it is just crazy that each alias have to be in order starting with _alias0. –  Aaron Renoir Feb 13 at 2:15
add comment

Okay according to the rc.conf man page this is the intended behavior.

Under the network_interfaces section it reads.

For each ifconfig_<interface>_alias<n> entry with an address 
family keyword, its contents are passed to ifconfig(8).  
Execution stops at the first unsuccessful access, 
so if something like this is present:

ifconfig_ed0_alias0="inet 127.0.0.251 netmask 0xffffffff"
ifconfig_ed0_alias1="inet 127.0.0.252 netmask 0xffffffff"
ifconfig_ed0_alias2="inet 127.0.0.253 netmask 0xffffffff"
ifconfig_ed0_alias4="inet 127.0.0.254 netmask 0xffffffff"

Then note that alias4 would not be added since the search
would stop with the missing ``alias3'' entry. Because of
this difficult to manage behavior, there is ifconfig_<interface>_aliases variable, 
which has the same functionality as ifconfig_<interface>_alias<n>   
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.