Add own service Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Add own service

Post by cc13 »

Hello,

After the unsuccessful attempt to connect my 2 RPi's via wireguard I started a try via vpnc. The goal is to connect the RPi3 client via Remote-Fritzxbox to have access to the remote network.

I installed vpnc and created a default-config-file with the VPN-Settings. That works fine:

Code: Select all

root@DietPi:/etc/vpnc# vpnc
VPNC started in background (pid: 28518)...
Now I try to create a service to start this connection with every boot of the RPi3. For that I created an additional file:

Code: Select all

root@DietPi:/etc/systemd/system# cat fritzbox.service
[Service]
ExecStart=/usr/sbin/vpnc
WorkingDirectory=/etc/vpnc
Restart=always
StandardOutput=journal+console
StandardError=journal+console
SyslogIdentifier=vpnc_fritzbox
User=root
Group=root

[Install]
WantedBy=multi-user.target
After adding this service via dietpi-services I tried to start the service but it failed:

Code: Select all

root@DietPi:/etc/systemd/system# dietpi-services start fritzbox
[ SUB1 ] DietPi-Services > start fritzbox
[FAILED] DietPi-Services | start : fritzbox
Here are the log:

Code: Select all

Warning: The unit file, source configuration file or drop-ins of fritzbox.service changed on disk. Run 'systemctl    │
      │ daemon-reload' to reload units.                                                                                      │
      │ ● fritzbox.service                                                                                                   │
      │    Loaded: bad-setting (Reason: Unit fritzbox.service has a bad unit file setting.)                                  │
      │   Drop-In: /etc/systemd/system/fritzbox.service.d                                                                    │
      │            └─dietpi-services_edit.conf                                                                               │
      │    Active: inactive (dead) since Wed 2020-11-18 09:02:58 CET; 45min ago                                              │
      │  Main PID: 32507 (code=killed, signal=TERM)
And

Code: Select all

Nov 18 09:47:58 DietPi systemd[1]: fritzbox.service: Service has more than one ExecStart= setting, which is
only allowed for Type=oneshot services. Refusing.
The systemctl daemon-reload I did, same result.

Any idea what I'm doing wrong?

Edit: In addition this service should start before the network drive mapping happens. ;-)
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Add own service

Post by Joulinar »

did you tried to add Type=oneshot into your service definition? At least thats what the error message suggesting ;)

Code: Select all

Nov 18 09:47:58 DietPi systemd[1]: fritzbox.service: Service has more than one ExecStart= setting, which is
only allowed for Type=oneshot services. Refusing.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Re: Add own service

Post by cc13 »

Ok, now I added Type=oneshot and after the next error message I changed Restart=always to Restart=no.

No, my name resolution is broken again (like in my wireguard post).

Code: Select all

root@DietPi:/# ping heise.de
ping: heise.de: Temporärer Fehler bei der Namensauflösung
I cannot apply the DNS settings again in Dietpi-Config/Network Options: Adapter as long the fritzbox_service is setup. If I remove the fritzbox_service entries I can repair the DNS settings. But I run then in the same issue with not starting fritzbox_service.

Code: Select all

Nov 18 14:25:10 DietPi systemd[1]: Starting fritzbox.service...                                                      │
      │ Nov 18 14:25:25 DietPi vpnc[30891]: terminated by signal: 15                                                         │
      │ Nov 18 14:25:26 DietPi systemd[1]: fritzbox.service: Succeeded.                                                      │
      │ Nov 18 14:25:26 DietPi systemd[1]: Started fritzbox.service. 

Code: Select all

root@DietPi:/# dietpi-services status fritzbox
[ SUB1 ] DietPi-Services > status fritzbox
[ INFO ] DietPi-Services | fritzbox             inactive (dead)
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Add own service

Post by Joulinar »

something is relay strange on your system. I did a test installation on my RPi3B+, connected to a mobile hotspot and was able to use Wireguard as client to connect back home to my RPi4B hosting my WireGuard server.

You would need to find out why your DNS settings are going to vanish all the time.

To check what is going on with your service, just run

Code: Select all

systemctl status fritzbox.service
journalctl -u fritzbox.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Re: Add own service

Post by cc13 »

Sometime I think the wireguard-issue is an issue with my provider or the router of the provider or the restriction of the provider. But at the moment I have no chance to put the RPi3 in another network/provider.

Code: Select all

root@DietPi:/# systemctl status fritzbox.service
● fritzbox.service
   Loaded: loaded (/etc/systemd/system/fritzbox.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Nov 18 14:17:49 DietPi systemd[1]: Started fritzbox.service.
Nov 18 14:22:42 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:22:42 DietPi vpnc_fritzbox[19144]: /usr/sbin/vpnc: unknown host `xxx.net'
Nov 18 14:22:42 DietPi systemd[1]: fritzbox.service: Main process exited, code=exited, status=1/FAILURE
Nov 18 14:22:42 DietPi systemd[1]: fritzbox.service: Failed with result 'exit-code'.
Nov 18 14:22:42 DietPi systemd[1]: Failed to start fritzbox.service.
Nov 18 14:25:10 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:25:25 DietPi vpnc[30891]: terminated by signal: 15
Nov 18 14:25:26 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 14:25:26 DietPi systemd[1]: Started fritzbox.service.

Code: Select all

root@DietPi:/# journalctl -u fritzbox.service
-- Logs begin at Wed 2020-11-18 13:18:34 CET, end at Wed 2020-11-18 15:15:15 CET. --
Nov 18 13:43:18 DietPi systemd[1]: fritzbox.service: Service has Restart= setting other than no, which isn't allowed fo
r Type=oneshot services. Refusing.
Nov 18 13:43:51 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 13:44:06 DietPi vpnc_fritzbox[396]: RTNETLINK answers: File exists
Nov 18 13:44:07 DietPi vpnc[545]: select: Interrupted system call
Nov 18 13:44:07 DietPi vpnc[395]: select: Interrupted system call
Nov 18 13:44:07 DietPi vpnc[395]: terminated by signal: 15
Nov 18 13:44:07 DietPi vpnc[545]: terminated by signal: 15
Nov 18 13:44:19 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 13:44:19 DietPi systemd[1]: Started fritzbox.service.
Nov 18 13:45:13 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 13:45:13 DietPi vpnc_fritzbox[5133]: /usr/sbin/vpnc: unknown host `xxx.net'
Nov 18 13:45:13 DietPi systemd[1]: fritzbox.service: Main process exited, code=exited, status=1/FAILURE
Nov 18 13:45:13 DietPi systemd[1]: fritzbox.service: Failed with result 'exit-code'.
Nov 18 13:45:13 DietPi systemd[1]: Failed to start fritzbox.service.
Nov 18 13:47:13 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 13:47:28 DietPi vpnc[16865]: HMAC mismatch in ESP mode
Nov 18 13:47:29 DietPi vpnc_fritzbox[16866]: RTNETLINK answers: File exists
Nov 18 13:47:29 DietPi vpnc[16865]: select: Interrupted system call
Nov 18 13:47:29 DietPi vpnc[16865]: terminated by signal: 15
Nov 18 13:47:29 DietPi vpnc[17168]: terminated by signal: 15
Nov 18 13:47:42 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 13:47:42 DietPi systemd[1]: Started fritzbox.service.
Nov 18 13:49:54 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 13:50:10 DietPi vpnc[28570]: HMAC mismatch in ESP mode
Nov 18 13:50:10 DietPi vpnc[28570]: HMAC mismatch in ESP mode
Nov 18 13:50:10 DietPi vpnc[28570]: HMAC mismatch in ESP mode
Nov 18 13:50:10 DietPi vpnc_fritzbox[28571]: RTNETLINK answers: File exists
Nov 18 13:50:11 DietPi vpnc[28570]: select: Interrupted system call
Nov 18 13:50:11 DietPi vpnc[28570]: terminated by signal: 15
Nov 18 13:50:11 DietPi vpnc[28888]: select: Interrupted system call
Nov 18 13:50:11 DietPi vpnc[28888]: terminated by signal: 15
Nov 18 13:50:11 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 13:50:11 DietPi systemd[1]: Started fritzbox.service.
Nov 18 14:11:37 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:11:53 DietPi vpnc_fritzbox[6743]: RTNETLINK answers: File exists
Nov 18 14:11:53 DietPi vpnc[6742]: select: Interrupted system call
Nov 18 14:11:53 DietPi vpnc[6742]: terminated by signal: 15
Nov 18 14:11:53 DietPi vpnc[6891]: terminated by signal: 15
Nov 18 14:12:06 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 14:12:06 DietPi systemd[1]: Started fritzbox.service.
Nov 18 14:15:32 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:15:32 DietPi vpnc_fritzbox[20615]: /usr/sbin/vpnc: unknown host `xxx.net'
Nov 18 14:15:32 DietPi systemd[1]: fritzbox.service: Main process exited, code=exited, status=1/FAILURE
Nov 18 14:15:32 DietPi systemd[1]: fritzbox.service: Failed with result 'exit-code'.
Nov 18 14:15:32 DietPi systemd[1]: Failed to start fritzbox.service.
Nov 18 14:17:20 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:17:36 DietPi vpnc_fritzbox[32206]: RTNETLINK answers: File exists
Nov 18 14:17:37 DietPi vpnc[32516]: select: Interrupted system call
Nov 18 14:17:37 DietPi vpnc[32204]: select: Interrupted system call
Nov 18 14:17:37 DietPi vpnc[32516]: terminated by signal: 15
Nov 18 14:17:37 DietPi vpnc[32204]: terminated by signal: 15
Nov 18 14:17:49 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 14:17:49 DietPi systemd[1]: Started fritzbox.service.
Nov 18 14:22:42 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:22:42 DietPi vpnc_fritzbox[19144]: /usr/sbin/vpnc: unknown host `xxx.net'
Nov 18 14:22:42 DietPi systemd[1]: fritzbox.service: Main process exited, code=exited, status=1/FAILURE
Nov 18 14:22:42 DietPi systemd[1]: fritzbox.service: Failed with result 'exit-code'.
Nov 18 14:22:42 DietPi systemd[1]: Failed to start fritzbox.service.
Nov 18 14:25:10 DietPi systemd[1]: Starting fritzbox.service...
Nov 18 14:25:25 DietPi vpnc[30891]: terminated by signal: 15
Nov 18 14:25:26 DietPi systemd[1]: fritzbox.service: Succeeded.
Nov 18 14:25:26 DietPi systemd[1]: Started fritzbox.service.
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Add own service

Post by Joulinar »

hmm some unknown host `xxx.net' messages. So we are down to the DNS challange. What DNS Server you are using? Some local one or from your provider? Or is your /etc/resolv.conf empty again?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Re: Add own service

Post by cc13 »

Code: Select all

root@DietPi:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 9.9.9.9
nameserver 149.112.112.112

Code: Select all

root@DietPi:~# ls -al /etc/res*
lrwxrwxrwx 1 root root   31 Nov 16 12:15 /etc/resolv.conf -> /etc/resolvconf/run/resolv.conf
If the the name resolution will not work, the IP-Adress from the Remote Fritzbox is added as the first nameserver in resolv.conf.
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Add own service

Post by Joulinar »

cc13 wrote: Wed Nov 18, 2020 5:59 pm If the the name resolution will not work, the IP-Adress from the Remote Fritzbox is added as the first nameserver in resolv.conf.
This I don't undertstand. What do mean by this

Nameserver 9.9.9.9 and 149.112.112.112 are fine. This is Quad9 global DNS. Can you try to resolve DNS of your fritz.box

Code: Select all

nslookup <your_dynDNS>
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Re: Add own service

Post by cc13 »

Code: Select all

root@DietPi:~# nslookup xxx.myfritz.net
Server:		9.9.9.9
Address:	9.9.9.9#53

Non-authoritative answer:
Name:	xxx.myfritz.net
Address: aa.xxx.yyy.ccc
Name:	xxx.myfritz.net
Address: xxx:xxx:xxx:xxx:xxx:xxx:xxx:xxx
What I meant was if it happens that the name resolution doesn't work and I looked into my resolve.conf there are 3 DNS servers in:

192.168.1.2 (local IP Fritzbox)
9.9.9.9
149.112.112.112
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Add own service

Post by Joulinar »

ok at least your myfritz address is recognised correctly with vpn client disabled.

I guess you VPN client is adding the DNS server entry. However you VPN client service is still failing?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply