Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

20 years ago
20 years ago
  1. # $OpenBSD: ifstated.conf,v 1.6 2005/02/07 06:08:10 david Exp $
  2. # This is a sample config for a pair of firewalls with two interfaces
  3. #
  4. # carp0 and carp1 have ip addresses on 192.168.3.0/24 and 192.168.6.0/24
  5. # respectively.
  6. # net.inet.carp.preempt must be enabled (set to 1) for this to work correctly.
  7. # Uncomment one of the following lines to force primary/backup status.
  8. # init-state primary
  9. # init-state backup
  10. carp_up = "carp0.link.up && carp1.link.up"
  11. carp_down = "!carp0.link.up && !carp1.link.up"
  12. carp_sync = "carp0.link.up && carp1.link.up || \
  13. !carp0.link.up && !carp1.link.up"
  14. # The "net" addresses are other addresses which can be used to determine
  15. # whether we have connectivity. Make sure the hosts are always up, or
  16. # test multiple ip's, 'or'-ing the tests.
  17. net = '( "ping -q -c 1 -w 1 192.168.6.8 > /dev/null" every 10 && \
  18. "ping -q -c 1 -w 1 192.168.3.8 > /dev/null" every 10)'
  19. # The peer addresses below are the real ip addresses of the OTHER firewall
  20. peer = '( "ping -q -c 1 -w 1 192.168.6.7 > /dev/null" every 10 && \
  21. "ping -q -c 1 -w 1 192.168.3.7 > /dev/null" every 10)'
  22. state auto {
  23. if $carp_up
  24. set-state primary
  25. if $carp_down
  26. set-state backup
  27. }
  28. state primary {
  29. init {
  30. run "ifconfig carp0 advskew 10"
  31. run "ifconfig carp1 advskew 10"
  32. }
  33. if ! $net
  34. set-state demoted
  35. }
  36. state demoted {
  37. init {
  38. run "ifconfig carp0 advskew 254"
  39. run "ifconfig carp1 advskew 254"
  40. }
  41. if $net
  42. set-state primary
  43. }
  44. state promoted {
  45. init {
  46. run "ifconfig carp0 advskew 0"
  47. run "ifconfig carp1 advskew 0"
  48. }
  49. if $peer || ! $net
  50. set-state backup
  51. }
  52. state backup {
  53. init {
  54. run "ifconfig carp0 advskew 100"
  55. run "ifconfig carp1 advskew 100"
  56. }
  57. # The "sleep 5" below is a hack to dampen the $carp_sync when we come
  58. # out of promoted state. Thinking about the correct fix...
  59. if ! $carp_sync && $net && "sleep 5" every 10
  60. if ! $carp_sync && $net
  61. set-state promoted
  62. }