# Do i need a static IP for any VPN setup?

**URL:** <https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312>\
**Category:** General\
**Created:** [February 10, 2023, 6:29am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312 "2023-02-10T06:29:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datanav](https://forum.mikrotik.com/letter_avatar/datanav/32/6_449c533f586939b6e5f246632a46421f.png) [@Datanav](https://forum.mikrotik.com/u/Datanav)\
**Post date:** [February 10, 2023, 6:29am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/1 "2023-02-10T06:29:56Z")

</div>

Am looking at using mikrotik devices to do some site to site VPN(branch to branch) but from all the tutorials/blogs that am looking at it seems that i need static public IP’s to perform the configurations.  
I have 58 branches spread across, does it ideally mean i need 58 public IP’s?  
Am just looking for clarification or maybe a solution of how i can go about this either using wireguard or Ipsec.

Thanks.

---

<div class="post-metadata">

**Author:** ![ConradPino](https://forum.mikrotik.com/letter_avatar/conradpino/32/6_449c533f586939b6e5f246632a46421f.png) [@ConradPino](https://forum.mikrotik.com/u/ConradPino)\
**Post date:** [February 10, 2023, 6:57am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/2 "2023-02-10T06:57:29Z")

</div>

Yes, 58, while local networks are typically private IP, every working Internet site has at least one dynamic or static public IP.

VPN can work with dynamic IP but not without public IP otherwise a connection to public Internet just doesn’t work.

IMO 58 sites is potentially complicated. Study carefully which sites need to connect directly.  
A hub and spoke model has fewest site to site connections; static public IP at hub is simpler.

---

<div class="post-metadata">

**Author:** ![Datanav](https://forum.mikrotik.com/letter_avatar/datanav/32/6_449c533f586939b6e5f246632a46421f.png) [@Datanav](https://forum.mikrotik.com/u/Datanav)\
**Post date:** [February 10, 2023, 7:06am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/3 "2023-02-10T07:06:40Z")

</div>

> [@](#):
>
> Yes, 58, while local networks are typically private IP, every working Internet site has at least one dynamic or static public IP.
> 
> VPN can work with dynamic IP but not without public IP otherwise a connection to public Internet just doesn’t work.
> 
> IMO 58 sites is potentially complicated. Study carefully which sites need to connect directly.  
> A hub and spoke model has fewest site to site connections; static public IP at hub is simpler.

If only mikrotik could support dynamic dns then setting up 58 sites would technically be easy.

---

<div class="post-metadata">

**Author:** ![ConradPino](https://forum.mikrotik.com/letter_avatar/conradpino/32/6_449c533f586939b6e5f246632a46421f.png) [@ConradPino](https://forum.mikrotik.com/u/ConradPino)\
**Post date:** [February 10, 2023, 8:53am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/4 "2023-02-10T08:53:46Z")

</div>

IMO that conclusion is premature. If we look at RouterOS OpenVPN documentation, only the client requires an IP address. [https://help.mikrotik.com/docs/display/ROS/OpenVPN](https://help.mikrotik.com/docs/display/ROS/OpenVPN)

Let’s choose one site as the “hub” - as long as hub router is powered up, it’s public IPv4 address is unlikely to change; it just keeps renewing it’s lease.  
Worst case, order a static address for hub site which can be a centrally located cloud server. The “spoke” sites don’t need a stable public IP address.

---

<div class="post-metadata">

**Author:** ![p3rad0x](https://forum.mikrotik.com/letter_avatar/p3rad0x/32/6_449c533f586939b6e5f246632a46421f.png) [@p3rad0x](https://forum.mikrotik.com/u/p3rad0x)\
**Post date:** [February 10, 2023, 9:04am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/5 "2023-02-10T09:04:50Z")

</div>

You don’t need a public static address for each branch. Depending on your needs you can get it setup with only 1 location having a static public address eg the Head office.

Setup the VPN server at the head office and connect all the clients to it. for 58 branches you can setup OSPF or BGP to redistribute the routes between them.

You can also look at using wire guard for the VPN or you can do good old l2tp with ipsec

---

<div class="post-metadata">

**Author:** ![bpwl](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/bpwl/32/2379_2.png) [@bpwl](https://forum.mikrotik.com/u/bpwl)\
**Post date:** [February 10, 2023, 10:20am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/6 "2023-02-10T10:20:07Z")

</div>

Not all VPN setup need static IP addresses. (See SSTP, PPTP, OVPN, etc … they at least accept a DNS FQN for the server in the “connect to”.)

Clients certainly don’t need a static IP, if they initiate the connection to the server. They can even be behind multiple NAT routers and use load balancing. (failover)  
Once the VPN is set up the communication is bi-directional.

Even the server can be Dynamic DNS defined with a variable IP address like on xDSL or home cable modem.  
And each MT router already has a Dynamic DNS entry with Mikrotik. See “IP Cloud” and DDNS setting.  
Other DDNS services (like No-IP) can be used as well.  
The VPN server can be behind NAT, but then the VPN server port needs to be DST-NAT forwarded. (ISP must either give a public IP or allow for this.)  
When the IP address of the VPN server connection changes, the VPN is dropped, and the client reconnects.

(I use 2 VPN servers on 2 different ISP even in different locations, with dynamic DNS, for continuus connection for and between the VPN client MT routers)

---

<div class="post-metadata">

**Author:** ![holvoetn](https://forum.mikrotik.com/letter_avatar/holvoetn/32/6_449c533f586939b6e5f246632a46421f.png) [@holvoetn](https://forum.mikrotik.com/u/holvoetn)\
**Post date:** [February 10, 2023, 10:56am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/7 "2023-02-10T10:56:10Z")

</div>

Using Wireguard you only need 1 static IP to use as endpoint for all peers, e.g. on head-office (and even that 1 static IP can be dynamic using e.g. Mikrotik’s own Cloud Ip DNS service provided that location allows port forwarding but this might complicate things a bit, especially when DNS service is unable to resolve DynDNS name).

All the peers may even be hiding behind CGNAT, it will work. But you need 1 static or dynamic IP. You could even use a public service as pivot point ? Then everything can be behind CGNAT.

---

<div class="post-metadata">

**Author:** ![bpwl](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/bpwl/32/2379_2.png) [@bpwl](https://forum.mikrotik.com/u/bpwl)\
**Post date:** [February 10, 2023, 3:38pm UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/8 "2023-02-10T15:38:32Z")

</div>

@holvoetn : Do you update the dDNS IP address in the MT Wireguard config, when the address has changed? Scripted ?  
New world here. Is indeed very convenient, works flawless when you found how to configure specific client devices, like Windows ( [https://www.makeuseof.com/how-to-set-up-wireguard-windows/](https://www.makeuseof.com/how-to-set-up-wireguard-windows/))  
What extra services , like “Tailscale” can/should be used for (dynamic)DNS based setup?

---

<div class="post-metadata">

**Author:** ![holvoetn](https://forum.mikrotik.com/letter_avatar/holvoetn/32/6_449c533f586939b6e5f246632a46421f.png) [@holvoetn](https://forum.mikrotik.com/u/holvoetn)\
**Post date:** [February 10, 2023, 3:56pm UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/9 "2023-02-10T15:56:55Z")

</div>

> [@](#):
>
> @holvoetn : Do you update the dDNS IP address in the MT Wireguard config, when the address has changed? Scripted ?

I use the Mikrotik Cloud DynDNS service as in .sn.mynetname.net.

It’s all peers with WG but let’s for simplicity sake talk about server and clients.  
Clients connect to server with dynamic name as endpoint.  
On server side, you do not set an endpoint. The clients initiate the connection when dialing in.  
If/when that ip changes, wireguard usually resolves on itself since it will detect another IP being used for the communication.  
That’s how wireguard works. Even when you set up a cell connection while driving with your car, hopping from base station to base station, even hopping from provider to provider, even crossing borders, … guaranteed your client device changes IP addresses a couple of times.  
I already did that when driving home from France (wife was driving, I was on the passenger seat with cell phone as hotspot and laptop connected via WG to home).  
Only when cell was really acquiring a new IP address, connection was temporarily lost. But then traffic starts flowing again.

I also had a CGNAT client connection in a vacation house in France (now sold, so bye bye France). On that device (SXT LTE6) I effectively had a script with netwatch to toggle peer status (re-initiating DNS resolving) when connection was down. Usually that’s only needed at boot time when WG interface starts before DNS resolving is active since again, wireguard is pretty good at re-resolving all that on itself during normal operation.

---

<div class="post-metadata">

**Author:** ![bpwl](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/bpwl/32/2379_2.png) [@bpwl](https://forum.mikrotik.com/u/bpwl)\
**Post date:** [February 10, 2023, 4:25pm UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/10 "2023-02-10T16:25:03Z")

</div>

Thx … aha … endpoint- **address** field accepts DNS not only IP address … .  
_My tunnel thinking :-/ 🙂_

---

<div class="post-metadata">

**Author:** ![anav](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/anav/32/2112_2.png) [@anav](https://forum.mikrotik.com/u/anav)\
**Post date:** [February 10, 2023, 9:24pm UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/11 "2023-02-10T21:24:04Z")

</div>

> [@](#):
>
> Thx … aha … endpoint- **address** field accepts DNS not only IP address … .  
> _My brain fried on wifi waves :-/ 🙂_

Fixed it for ya! 🙂

---

<div class="post-metadata">

**Author:** ![aoakeley](https://forum.mikrotik.com/letter_avatar/aoakeley/32/6_449c533f586939b6e5f246632a46421f.png) [@aoakeley](https://forum.mikrotik.com/u/aoakeley)\
**Post date:** [February 11, 2023, 5:38am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/12 "2023-02-11T05:38:55Z")

</div>

> [@](#):
>
> I have 58 branches spread across, does it ideally mean i need 58 public IP’s?

Other than if these 58 branches have internet connectivity they much have a public IP somewhere along the way, otherwise they would not be able to connect to the internet… But I presume this is not what you are getting at, and what you mean is Static Public IP Addresses?

A more full answer would be that only one site needs a “Static Public IP” so that all the other sites can connect to that site, and as someone else said then use OSPF to make your life a little bit easier when it comes to the routing (so you don’t have to put static routes in everywhere). You can manage using only a Public IP (not static) at one of the sites, and use Dynamic DNS. But I would suggest that this is not ideal for reliability.

You CAN also do this is none of the sites have a directly attached public IP (e.g. if every site is behind CGNAT) by putting a virtual Mikrotik router with any number of cloud providers (Azure or AWS would be the obvious choices) and then using that as a peering point for all the remote sites.

Wireguard is probably going to be easier for this type of config.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Datanav](https://forum.mikrotik.com/letter_avatar/datanav/32/6_449c533f586939b6e5f246632a46421f.png) [@Datanav](https://forum.mikrotik.com/u/Datanav)\
**Post date:** [February 11, 2023, 6:39am UTC](https://forum.mikrotik.com/t/do-i-need-a-static-ip-for-any-vpn-setup/164312/13 "2023-02-11T06:39:41Z")

</div>

Thanks everyone who has commented. I technically now have an idea on how to go about plus have received more information from client that not all sites need to talk to HQ just a few branches that need to talk to each other exclusively, maybe much later is when they will need to all talk to the HQ. Other than that the clarity is satisfactory!  
Thanks.
