log syslog all;
router id {{address}};

protocol device {
}
#protocol direct {
#  disabled;
#  ipv4;
#  ipv6;
#}

{% for interface in lan_interfaces %}
protocol direct {
  ipv4;
  ipv6;
  interface "{{interface}}";
}
{% endfor %}

protocol kernel {
  ipv4 {
    export all;
  };
  #kernel table main;
}
protocol kernel {
  ipv6 { export all; };
}

{% for connection in connections %}
{% if connection.protocol != "null" and connection.remoteLocalAddress != address %}
ipv4 table {{connection.name.replace("-", "_")}};
protocol static {
  ipv4 {
    table {{connection.name.replace("-", "_")}};
  };
  igp table master4;
  route 0.0.0.0/0 recursive {{connection.remoteLocalAddress}};
}
protocol kernel {
  ipv4 {
    table {{connection.name.replace("-", "_")}};
    export all;
  };
  kernel table {{connection.remoteMark}};
}
{% endif %}
{% endfor %}

protocol ospf v2 {
  ipv4 {
    import all;
    export where source ~ [ RTS_DEVICE, RTS_STATIC ];
  };
  area 0 {
    networks {
      10.0.0.0/8;
    };
#		interface "eth*" {
#			type broadcast;		# Detected by default
#			cost 10;		# Interface metric
#			hello 5;		# Default hello perid 10 is too long
#		};
{% for connection in connections %}
{% if connection.protocol != "null" and connection.remoteLocalAddress != address %}
    interface "{{connection.name}}" {
      type ptp;
{% if connection.outbound %}
      cost {{connection.metric}};
{% else %}
      cost 50000;
{% endif %}
      hello 5;
    };
{% endif %}
{% endfor %}

{% for interface in lan_interfaces %}
    interface "{{interface}}" {
      type broadcast;
      cost 1;
      hello 5;
    };
{% endfor %}

    interface "dummy0" {
      stub;			# Stub interface, just propagate it
    };
  };
}
