Port Forwarding by Autostart

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
Caporeira
Posts: 30
Joined: Sat May 29, 2021 11:21 pm

Port Forwarding by Autostart

Post by Caporeira »

What is the easiest way to start this script (port forwarding) on DietPi by Autostart ?

Code: Select all

ssh -fNT 192.168.8.200 -p 22 \
    	-L 10.144.xx.xx:yyy:192.168.0.104:yyy \
	-L 10.144.xx.xx:yyyy:192.168.0.104:yyyy
User avatar
trendy
Posts: 368
Joined: Tue Feb 25, 2020 2:54 pm

Re: Port Forwarding by Autostart

Post by trendy »

There used to be /etc/rc.local for that, but not anymore. You can try to add a custom cronjob in /etc/cron.d/ with @reboot. Keep in mind that you also need to specify the user who will run the command.
https://phoenixnap.com/kb/crontab-reboot
Alternatively, look at dietpi-autostart option 14.
User avatar
Joulinar
Posts: 5996
Joined: Sat Nov 16, 2019 12:49 am

Re: Port Forwarding by Autostart

Post by Joulinar »

Or use a systemd service to start on boot. Or DietPi custom script available as autostart option.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3357
Joined: Sat Nov 18, 2017 6:21 pm

Re: Port Forwarding by Autostart

Post by MichaIng »

Easiest is probably to put the script into /var/lib/dietpi/postboot.d. All contained scripts are executed as root user independant of a login once at the end of the boot sequence.
Post Reply