Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:vpn:ipsec:strongswan:overlappingsubnets [2020/08/26 02:07] – [Real Life Example] 192.168.2.77 should be changed to 192.168.3.13 passwinddocs:guide-user:services:vpn:strongswan:overlappingsubnets [2020/11/11 09:57] – obsolete links vgaetera
Line 1: Line 1:
 ====== IPsec With Overlapping Subnets ====== ====== IPsec With Overlapping Subnets ======
-| For an overview over all existing Virtual private network (VPN)-related articles in the OpenWrt wiki, please visit [[docs:guide-user:services:vpn:overview]] | +One of the most common problems when establishing VPN tunnels are overlapping subnets. I.e. the IP adresses at least on one tunnel end conflict with the existing setup. Very often the firewall administrator is struggling with such a setup because special settings have to take place to create correct address translation for a clean solution. Hopefully this article will help the OpenWrt user to make it fuss-free. We assume you have read the [[basics|basics]] and the [[docs:guide-user:services:vpn:strongswan:firewall|firewall]] setup guide for IPsec.
-:!: This page is about strongswan. The old racoon documentation can be found [[..:racoon:overlappingsubnets|here]]. +
- +
-One of the most common problems when establishing VPN tunnels are overlapping subnets. I.e. the IP adresses at least on one tunnel end conflict with the existing setup. Very often the firewall administrator is struggling with such a setup because special settings have to take place to create correct address translation for a clean solution. Hopefully this article will help the OpenWrt user to make it fuss-free. We assume you have read the [[basics|basics]] and the [[docs:guide-user:services:vpn:ipsec:strongswan:firewall|firewall]] setup guide for IPsec.+
  
 ===== Real Life Example ===== ===== Real Life Example =====
Line 37: Line 34:
 Now that we know where and how to change IP addresses we will make a short excursion into the Linux netfilter deeps. We have no real choices to implement the above explained translation rules. Now that we know where and how to change IP addresses we will make a short excursion into the Linux netfilter deeps. We have no real choices to implement the above explained translation rules.
  
-  * **Source address translation**: Required for outgoing packets. The firewall allows source address translation only in the POSTROUTING chain of the NAT table. This is the very last step of kernel packet mangling. This implies a feature and some trouble. All filter rules are applied before source translation. So they can be implemented with the original packets IP addresses. We have no burden to work on translated packets. On the other hand the firewall cannot know that the packet is routed into an IPsec tunnel before the translation takes place. As mentioned [[..:racoon:firewall#preface|here]] our firewall script already observes these quirks. +  * **Source address translation**: Required for outgoing packets. The firewall allows source address translation only in the POSTROUTING chain of the NAT table. This is the very last step of kernel packet mangling. This implies a feature and some trouble. All filter rules are applied before source translation. So they can be implemented with the original packets IP addresses. We have no burden to work on translated packets. On the other hand the firewall cannot know that the packet is routed into an IPsec tunnel before the translation takes place. As mentioned [[..:ipsec:racoon:firewall#preface|here]] our firewall script already observes these quirks. 
   * **Desintation address translation**: Required for incoming packets. The right place is the PREROUTING chain of the NAT table. The firewall will jump there before any filter chain is traversed. And again we have the possibility to build filter rules based on how we "see" our internal network topology - with the real local addresses.   * **Desintation address translation**: Required for incoming packets. The right place is the PREROUTING chain of the NAT table. The firewall will jump there before any filter chain is traversed. And again we have the possibility to build filter rules based on how we "see" our internal network topology - with the real local addresses.
   * **iptables module**: When most of us think about address translation in the kernel the SNAT and DNAT rules come into mind. If you dig into the documentation you will soon discover that they work well only on single addresses. If you provide address ranges these modules will apply some kind of randomness. So what we need is a 1:1 subnet mapping. The command of interest is **NETMAP**. It will replace the higher address bits of a IP address with a new subnet while keeping the lower bits. This will help us to stay deterministic and to keep number of firewall rules small.   * **iptables module**: When most of us think about address translation in the kernel the SNAT and DNAT rules come into mind. If you dig into the documentation you will soon discover that they work well only on single addresses. If you provide address ranges these modules will apply some kind of randomness. So what we need is a 1:1 subnet mapping. The command of interest is **NETMAP**. It will replace the higher address bits of a IP address with a new subnet while keeping the lower bits. This will help us to stay deterministic and to keep number of firewall rules small.
Line 54: Line 51:
 ===== Configuration ===== ===== Configuration =====
  
-Nice to know, that the configuration is very simple. The [[basics#ike.daemon|ipsec]] and [[docs:guide-user:services:vpn:ipsec:strongswan:firewall#vpn.firewall.script|firewall]] scripts will take care of the required settings. You just have to add a **local_nat** configuration line into the tunnel section of your [[docs:guide-user:services:vpn:ipsec:strongswan:basic|/etc/config/ipsec]] file.+Nice to know, that the configuration is very simple. The [[basics#ike.daemon|ipsec]] and [[docs:guide-user:services:vpn:strongswan:firewall#vpn.firewall.script|firewall]] scripts will take care of the required settings. You just have to add a **local_nat** configuration line into the tunnel section of your [[docs:guide-user:services:vpn:strongswan:configuration|/etc/config/ipsec]] file.
  
 <code> <code>
Line 69: Line 66:
  
 ===== What's Next ===== ===== What's Next =====
-OpenWrt as a central VPN gateway for [[docs:guide-user:services:vpn:ipsec:strongswan:roadwarrior|road warriors]].+OpenWrt as a central VPN gateway for [[docs:guide-user:services:vpn:strongswan:roadwarrior|road warriors]].
  
  • Last modified: 2023/03/18 23:50
  • by ryanc