Connecting the router to the server

If you are using an Enterprise or Personal cloud server, all smart home controllers will work with the cloud server through an Internet gateway. In the case of a SmartESP smart home, the gateway will be a regular Mikrotik router, which you may already have or may need to purchase. Don't worry, this is an inexpensive router and you can read about how to choose and configure it in the documentation: Choosing a router and Configuring a router.

Attention! If you are using your own Local Local server, you do not need to connect the router to the server! Instead, go straight to the next step - adding the controller to the project.

After installing and configuring the router, you need to connect it to the server. To do this on your server, go to the Router section and add a new one. Give it a name and choose its type and VPN connection option.

Let's go into more detail here. The type of router affects whether the server will be able to manage it remotely. That is, if you have a router firm Mikrotik and it is configured accordingly, then work with it can be greatly simplified, thanks to its API. If you have a different router, then in this case you will have to make some settings yourself.

Now the option of VPN connection. There are two options available: PPTP and L2TP with encryption IPsec. The variant PPTP, is inferior to L2TP in terms of encryption reliability, but wins in simplicity and ease. If you are confident in the reliability of your Internet provider, for example, if it is a mobile operator, you can use PPTP protocol as less resource-intensive and fast. If you are sensitive to security issues, then choose the option L2TP.

In any case, you will be much more secure thanks to any VPN-connection, unlike the option Not required. This option assumes that your router has a "white" (permanent public) IP address (which is then specified below). But, we will not dwell on it in detail, because this option is used only by experienced users and only for testing.

Let's consider only the options for configuring VPN connections.


PPTP option

Let's start with the most popular one PPTP. After adding the router, be sure to click on the Enable button so that it becomes green. Then click the plus symbol and see the personalized settings for the VPN connection.

Open the settings page of your home router. Go to the section Interfaces and click Add New and select PPTP Client.

Give a clear name to the VPN-connection, for example:pptp-smart. Then copy the server address, login and password. Be sure to check that the option Add Default Route is not selected .

Click Ok. The connection appears in the list and if you open it, you can see the status: connected. That's it!


L2TP variant

The L2TP variant is a bit more complicated. Let's go back to the server and add a second VPN. We get its connection parameters. Let's go back to the router settings page. First, go to the IP section and select IPsec. Next, go to the tab Proposals and open the profile default.

Here at the very end for the option PFS Group we put the option none.

Save. Close. Go to Interfaces and click Add New and select L2TP Client. Give a clear name to our VPN connection, for example: l2tp-smart. Next, copy the server address, login and password. Enable encryption IPsec and be sure to specify Secret. Also, make sure that the option Add Default Route is not selected.

Click Ok. The connection appears in the list and if you open it, you can see its status: connected. Done.

Now there are two active connections, you can see them if you go to IP and Routes. As you can see the IP address of the server for PPTP is 10.10.1.1 and for L2TP - 11.11.1.1.

Of course, we don't need two connections at once, so we can remove one of them.


Removing filter restrictions

The next step is to allow data movement over the created interface. To do this, go to IP and select Firewall.

Here on the tab Filter Rules we find the rule Drop all not coming from LAN and open it for editing. Next, find the rule Input Interface and select here our VPN interface connection to the server that you created before: l2tp-smart или pptp-smart . Be sure to put a negative exclamation mark in front of it.

Click Ok. Done.

This completes the stage of connecting the router to the server and then you can register the controllers on the server. It is as simple as possible to do it automatically through the server, but for this you must have a router Mikrotik, кроме этого , you will need to activate access via API.