Ran this script:
===== TEST SCRIPT START =====
#!/bin/sh
GARP_SYSCTL=net.link.ether.inet.garp_rexmit_count
IF=em0
ADDR=172.23.115.88
NETADDR="${ADDR}/24"
ADDR2=172.23.115.89
NETADDR2="${ADDR2}/24"
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $*"
}
log "Starting tcpdump to display GARPs"
tcpdump -vvv -i $IF "(arp host ${ADDR}) or (arp host ${ADDR2})" &
DUMPPID=$!
log "Current value if $GARP_SYSCTL:"
sysctl $GARP_SYSCTL
log "Setting value of ${GARP_SYSCTL} to 0"
sysctl ${GARP_SYSCTL}=0
log "Adding address ${NETADDR} to $IF: expect a single GARP"
ifconfig $IF inet ${NETADDR} alias
sleep 10
log "Removing address ${NETADDR} from $IF"
ifconfig $IF inet ${NETADDR} -alias
log "Setting value of ${GARP_SYSCTL} to 4"
sysctl ${GARP_SYSCTL}=4
log "Adding address ${NETADDR} to $IF: expect 5 GARPs"
ifconfig $IF inet ${NETADDR} alias
sleep 32
log "Removing address ${NETADDR} from $IF"
ifconfig $IF inet ${NETADDR} -alias
log "Adding address ${NETADDR} to $IF: expect 3 GARPs (address will be deleted before all 5 can be sent)"
ifconfig $IF inet ${NETADDR} alias
sleep 6
log "Removing address ${NETADDR} from $IF"
ifconfig $IF inet ${NETADDR} -alias
(
log "Adding address ${NETADDR} to $IF: expect 5 GARPs"
ifconfig $IF inet ${NETADDR} alias
sleep 32
log "Removing address ${NETADDR} from $IF"
ifconfig $IF inet ${NETADDR} -alias
) &
(
log "Adding address ${NETADDR2} to $IF: expect 3 GARPs (address will be deleted before all 5 can be sent)"
ifconfig $IF inet ${NETADDR2} alias
sleep 6
log "Removing address ${NETADDR2} from $IF"
ifconfig $IF inet ${NETADDR2} -alias
) &
sleep 35
kill $DUMPPID
log "Interface $IF should be back to original address(es) now:"
ifconfig $IF
log "Test done"
===== TEST SCRIPT END =====
Got this output showing proper operation:
===== TEST OUTPUT START =====
2016-08-29 11:16:34 Starting tcpdump to display GARPs
2016-08-29 11:16:34 Current value if net.link.ether.inet.garp_rexmit_count:
tcpdump: listening on em0, link-type EN10MB (Ethernet), capture size 262144 bytes
net.link.ether.inet.garp_rexmit_count: 4
2016-08-29 11:16:34 Setting value of net.link.ether.inet.garp_rexmit_count to 0
net.link.ether.inet.garp_rexmit_count: 4 -> 0
2016-08-29 11:16:34 Adding address 172.23.115.88/24 to em0: expect a single GARP
11:16:34.893874 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
2016-08-29 11:16:44 Removing address 172.23.115.88/24 from em0
2016-08-29 11:16:44 Setting value of net.link.ether.inet.garp_rexmit_count to 4
net.link.ether.inet.garp_rexmit_count: 0 -> 4
2016-08-29 11:16:44 Adding address 172.23.115.88/24 to em0: expect 5 GARPs
11:16:45.002455 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:16:46.065847 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:16:48.089488 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:16:52.089662 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:00.089678 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
2016-08-29 11:17:17 Removing address 172.23.115.88/24 from em0
2016-08-29 11:17:17 Adding address 172.23.115.88/24 to em0: expect 3 GARPs (address will be deleted before all 5 can be sent)
11:17:17.100189 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:18.156096 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:20.189011 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
2016-08-29 11:17:23 Removing address 172.23.115.88/24 from em0
2016-08-29 11:17:23 Adding address 172.23.115.88/24 to em0: expect 5 GARPs
2016-08-29 11:17:23 Adding address 172.23.115.89/24 to em0: expect 3 GARPs (address will be deleted before all 5 can be sent)
11:17:23.207698 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:23.214390 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.89 tell 172.23.115.89, length 28
11:17:24.240741 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.89 tell 172.23.115.89, length 28
11:17:24.240825 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:26.251366 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:26.251443 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.89 tell 172.23.115.89, length 28
2016-08-29 11:17:29 Removing address 172.23.115.89/24 from em0
11:17:30.250293 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
11:17:38.289407 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.23.115.88 tell 172.23.115.88, length 28
2016-08-29 11:17:55 Removing address 172.23.115.88/24 from em0
17 packets captured
124 packets received by filter
0 packets dropped by kernel
2016-08-29 11:17:58 Interface em0 should be back to original address(es) now:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:0c:29:a2:6b:3b
inet6 fe80::20c:29ff:fea2:6b3b%em0 prefixlen 64 scopeid 0x1
inet 172.16.211.154 netmask 0xffffff00 broadcast 172.16.211.255
nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
2016-08-29 11:17:58 Test done
===== TEST OUTPUT END =====