Running mopidy on a raspberry pi connected to my stereobox (receiver/amplifier whatever you will name it). Everyone linked to our local network can open mopidy on their device by entering http://musicbox:6680. Now is the only purpose of this box serving mopidy and spotify connect, it would be likely to have mopidy look like it’s running on port 80. Therefor I added a simple iptablerule.
pi@musicbox:~ $ sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 6680
Verifying the rule:
pi@musicbox:~ $ sudo iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
7 420 REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 6680
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
And when fed up with the rule, just remove all these nat rules:
pi@musicbox:~ $ sudo iptables -t nat -F
To make this new iptable rule persistent on reboot, I used these commands:
$ cd /etc
$ sudo mkdir iptables
$ sudo su
$ /sbin/iptables-save > /etc/iptables/rules.v4
$ exit
$ sudo apt install iptables-persistent
-- found that this installation asks to create the /etc/iptables/rules.v4, not checked whether first steps can be skipped.
check installation with:
$ sudo systemctl status netfilter-persistent.service