12 063
правки
(Новая страница: «Create a certificate signing request (with the name corresponding to the serial number of the controller, in this case that's A7ZO7UCC): <pre> cd /etc/openvpn/eas…») |
|||
(не показано 29 промежуточных версий этого же участника) | |||
Строка 245: | Строка 245: | ||
Signed <code>A7ZO7UCC certificate.crt</code> copy to the controller in the directory <code>/etc/openvpn/easy-rsa/keys</code>. | Signed <code>A7ZO7UCC certificate.crt</code> copy to the controller in the directory <code>/etc/openvpn/easy-rsa/keys</code>. | ||
On the server in the configuration file (<code>/etc/vpn/server.conf</code>) see which client-address match file is specified in the <code>ifconfig-pool-persist < /code> parameter and add the address for the client-controller from the network address range described in the <code>server</code> parameter of the configuration file to this file. | |||
For example, | |||
<pre> | <pre> | ||
service openvpn stop | service openvpn stop | ||
mcedit /etc/openvpn/ipp.txt | mcedit /etc/openvpn/ipp.txt | ||
</pre> | </pre> | ||
Add the line <code>A7ZO7UCC,10.8.0.48</code> | |||
<pre>service openvpn start</pre> | <pre>service openvpn start</pre> | ||
For the second server instance, we perform the same operation with its configuration files, the IP addresses should be different, for example, add an entry | |||
<code>A7ZO7UCC,10.9.0.48</code> | <code>A7ZO7UCC,10.9.0.48</code> | ||
The configuration files for the client on the controller for the two connections will be stored in the <code>/etc/openvpn/client files.conf</code> and <code>/etc/openvpn/client1.conf</code>. | |||
Contents of the client configuration file: | |||
<pre> | <pre> | ||
client | client | ||
Строка 279: | Строка 279: | ||
link-mtu 1542 | link-mtu 1542 | ||
keysize 128 | keysize 128 | ||
#keysize 128 - | #keysize 128 - for compatibility with existing clients | ||
</pre> | </pre> | ||
In the configuration file of the second vpn connection, <code>CLIENT1.conf</code> replace <code>proto udp</code> with <code>proto tcp</code> and specify the second IP address of the server in the <code>remote</code>parameter. | |||
Startup of the OpenVPN service on the controller is enabled by the command: | |||
<pre>update-rc.d openvpn defaults</pre> | <pre>update-rc.d openvpn defaults</pre> | ||
Check server availability | |||
<code>ping 10.8.0.1</code> | <code>ping 10.8.0.1</code> | ||
Строка 293: | Строка 293: | ||
== AutoSSH == | == AutoSSH == | ||
Another fallback controller connection will be based on the <code>AutoSSH</code>. The mechanism of work is as follows: SSH-connection from the controller to the server is established, and the ssh-port of the controller is forwarded to one of the free ports on the localhost server. Service аutossh ensures that the ssh connection is not broken, and in case of the gap restores it. Recovery is not instantaneous — for a while, the port used on the server's <code>localhost</code> is held by the <code>sshd</code>daemon. | |||
Install on the controller <code>apt-get install autossh</code>. Generate a key pair for the user <code>root</code>: | |||
<pre>ssh-keygen </pre> | <pre>ssh-keygen </pre> | ||
Password is empty. | |||
To maintain remote connections, create a user <code>remote</code> on the server with the shell <code>/bin/false</code>: | |||
< | <заранее>команду adduser --Home /для дома/дистанционный --оболочку /bin/false в удаленных и </pre> | ||
Here, in file <code>/home/remote/.ssh/authorized_keys</code> on the server, we add key created on the controller <code>/root/.ssh/id_rsa.pub</code> with the preamble | |||
<code>no-agent-forwarding,no-X11-forwarding,permitopen="localhost:62001" </code> | <code>no-agent-forwarding,no-X11-forwarding,permitopen="localhost:62001" </code> | ||
this will provide additional security for the server when the controller is connected. Port 62001 is the port of the localhost server to which the ssh port of this controller will be redirected. | |||
The first time we connect from the controller to the server manually: | |||
<pre>ssh remote@vpn.mydomain.com </pre> | <pre>ssh remote@vpn.mydomain.com </pre> | ||
On the controller, create a file <code>\etc\systemd\system\autossh.service</code> to run it <code>autossh</code> as a service: | |||
Строка 335: | Строка 335: | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
</pre> | </pre> | ||
Add service to autorun on the controller | |||
<pre>systemctl enable autossh.service</pre> | <pre>systemctl enable autossh.service</pre> | ||
After starting the service, we can connect to the controller on the server using the command | |||
<pre>ssh 127.0.0.1 -p 62001</pre> | <pre>ssh 127.0.0.1 -p 62001</pre> | ||
== | == Data transfer from controller to the cloud == | ||
To send MQTT messages from the controller to the cloud service, the MQTT bridge is used, the configuration of which is configured on the controller in the file <code>\mnt\data\etc\mosquito\conf.d\bridge.conf</code> | |||
<pre> | <pre> | ||
connection wb_devices_cloud.wb_A7ZO7UCC | connection wb_devices_cloud.wb_A7ZO7UCC | ||
Строка 359: | Строка 359: | ||
</pre> | </pre> | ||
Then run the command | |||
<pre> | <pre> | ||
Строка 366: | Строка 366: | ||
If you want to transfer data to multiple servers at the same time, create multiple <code>connection</code>partitions. | |||
== | == Possible GPRS connection problems == | ||
There can be several possible reasons for the lack of GPRS connection. | |||
* | * The paid traffic limit has ended. | ||
* | * Low voltage, poor contact to the antenna. | ||
* | * SIM cards of some operators are designed only for 4G-network, 3G-connection to install them will not work. | ||
* | * Check if the SIM card is inserted correctly into the slot. | ||
* | * The SIM card may not be working. | ||
* | * Your data plan does not include packet data. | ||
Before you go to your personal account and call the provider, you can perform a number of simple checks. | |||
Run the command | |||
<pre>gammu networkinfo</pre> | <pre>gammu networkinfo</pre> | ||
Строка 396: | Строка 396: | ||
</pre> | </pre> | ||
It is important that the controller is connected to the packet data network <pre>(GPRS : attached)</pre> and GPRS connection is established. | |||
Then evaluate the signal strength in minicom with <code>AT+CSQ</code> | |||
You will get the result as <code>13.99</code> | |||
The first digit shows the signal strength: > 9 — satisfactory, > 14 — good, > 19 — excellent. Low and unstable CSQ values mean that the antenna is poorly positioned, carelessly connected, radio placement is unfavorable. | |||
If both checks are passed, but there is no connection, contact your provider (check in your personal account), you can check the SIM card in your smartphone. |
правки