{"id":214,"date":"2011-01-09T19:57:49","date_gmt":"2011-01-09T17:57:49","guid":{"rendered":"http:\/\/www.rinta-aho.org\/blog\/?p=214"},"modified":"2015-11-03T12:13:36","modified_gmt":"2015-11-03T10:13:36","slug":"openbsd-and-duplicate-next-hop-routers","status":"publish","type":"post","link":"http:\/\/www.rinta-aho.org\/blog\/openbsd-and-duplicate-next-hop-routers\/","title":{"rendered":"OpenBSD and duplicate next hop routers"},"content":{"rendered":"<p>As I describe in an <a href=\"http:\/\/www.rinta-aho.org\/blog\/?p=168\">earlier blog post<\/a>, I am running an OpenBSD packet filter firewall which has three network interfaces connected to the same ISP. Everything worked so well until the ISP changed something in their configuration and two of the interfaces started to get the same next hop router (gateway) through DHCP configuration. This obviously causes problems with e.g. ARP and routing in general. The solution to this was to start using the &#8220;routing domain&#8221; feature of OpenBSD.<\/p>\n<p>All interfaces are in routing domain &#8220;0&#8221; by default. I then set the two &#8220;extra&#8221; outgoing interfaces to routing domains &#8220;1&#8221; and &#8220;2&#8221;. That way each outgoing network interface has its own routing table and ARP table, and routing\/ARP problems with the &#8220;duplicate next hop&#8221; were fixed. However, by definition, routing doesn&#8217;t work between routing domains. Luckily I found a way around this by tweaking pf.conf. The solution was to<\/p>\n<p>a) split the &#8220;binat&#8221; rules and use &#8220;rtable&#8221; keyword for the rule used for incoming packets, and<br \/>\nb) add the &#8220;rtable&#8221; keyword for outgoing packets.<\/p>\n<p>That way the route lookup is done on the correct routing tables for both incoming and outgoing packets.<\/p>\n<p>Here are the modified sections in \/etc\/pf.conf:<br \/>\n<code><br \/>\n# binat on em2 for host \"ps3\"<br \/>\nmatch out on $if_ext3 inet from $ps3 to any nat-to $if_ext3 static-port<br \/>\nmatch in  on $if_ext3 inet from any to $if_ext3 rdr-to $ps3 <strong>rtable 0<\/strong><\/p>\n<p># binat on em1 for host \"core7\"<br \/>\nmatch out on $if_ext2 inet from $core7 to any nat-to $if_ext2 static-port<br \/>\nmatch in  on $if_ext2 inet from any to $if_ext2 rdr-to $core7 <strong>rtable 0<\/strong><\/p>\n<p># NAT on em0 for the rest of the hosts<br \/>\nmatch out on $if_ext1 from $home_net_v4 nat-to ($if_ext1)<\/p>\n<p>...<\/p>\n<p>pass out quick on $if_ext1 inet from ($if_ext1) modulate state<br \/>\npass out quick on $if_ext2 inet from ($if_ext2) modulate state <strong>rtable 1<\/strong><br \/>\npass out quick on $if_ext3 inet from ($if_ext3) modulate state <strong>rtable 2<\/strong><br \/>\n<\/code><\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"http:\/\/www.facebook.com\/sharer.php?u=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;t=OpenBSD%20and%20duplicate%20next%20hop%20routers&#038;s=100&#038;p&#091;url&#093;=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=OpenBSD%20and%20duplicate%20next%20hop%20routers\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;text=OpenBSD%20and%20duplicate%20next%20hop%20routers\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-reddit nolightbox\" data-provider=\"reddit\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Reddit\" href=\"https:\/\/www.reddit.com\/submit?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;title=OpenBSD%20and%20duplicate%20next%20hop%20routers\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"reddit\" title=\"Share on Reddit\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/reddit.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-pinterest nolightbox\" data-provider=\"pinterest\" target=\"_blank\" rel=\"nofollow\" title=\"Pin it with Pinterest\" href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;media=&#038;description=OpenBSD%20and%20duplicate%20next%20hop%20routers\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"pinterest\" title=\"Pin it with Pinterest\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/pinterest.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214&#038;title=OpenBSD%20and%20duplicate%20next%20hop%20routers\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=OpenBSD%20and%20duplicate%20next%20hop%20routers&#038;body=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F214\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>As I describe in an earlier blog post, I am running an OpenBSD packet filter firewall which has three network interfaces connected to the same ISP. Everything worked so well until the ISP changed something in their configuration and two of the interfaces started to get the same next hop router (gateway) through DHCP configuration. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.rinta-aho.org\/blog\/openbsd-and-duplicate-next-hop-routers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;OpenBSD and duplicate next hop routers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-openbsd"],"_links":{"self":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/comments?post=214"}],"version-history":[{"count":5,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":429,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/214\/revisions\/429"}],"wp:attachment":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}