Hi picores
I'd like not to wait for all the Squeezebox Radio to implement DNS
resolution for target LMS Servers,
and would like to ask the devs to consider something like this:
- PiCorePlayer lets me set up a virtual eth with static IP
- And a Domain that traffic to this IP will be redirected to (because
the IP is dynamic)
- let me set up all the dummy SB Radios to point to that address which
handles the "routing".
The beauty would be to have a picoreplayer AND could add a range of
addidional hardware with buttons.
Thanks
Best Manu
This may be a thraightforward script to start from:
Code:
--------------------
#!/bin/bash
# Credits go to
# http://unix.stackexchange.com/questions/172293/ip-routing-to-domain
# TrialnErrorer: manu
# The idea is to have a localhost to have a static IP and redirect to a
dynamic host in the net.
# To provide a help for boxes that don't (yet) understand the beauty of DNS.
# Tested on an old ALIX with an old debian
# Using a virtual interface in eth0:0
# Todo: The same for more ports, also for UDP
# Test:
NOIPNAME=google.com
# The IP on the box inside the local net (behind NAT) which should redirect
# Tested with a virtual interface (eth0:0)
LOCALLISTENIP="192.168.100.11"
# Listening on this port (local)
LOCALLISTENPORT="80"
# Redirecting to this port (internet)
SENDTOPORT="80"
REMEMBERFILE="/var/run/oldip.txt"
# 8.8.8.8 is an expensive ip
HOSTLINE=$(host $NOIPNAME 8.8.8.8 | grep 'has address')
HOSTLEN=$(echo $HOSTLINE | wc -m)
# Make sure the return string is > 8 characters (1.2.3.4\n)
if [ $HOSTLEN -lt 8 ]; then
# Host resolve failure
echo "Bad host"
exit 1
fi
# Extract the IP from the return string.
DYNIP=$(echo $HOSTLINE | sed -rn 's/^.*
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/p')
# first time... ;-)
if [ -f "$REMEMBERFILE" ];then
OLDIP=$(cat "$REMEMBERFILE")
fi
if [ "x$DYNIP" = "x$OLDIP" ]; then
echo "IP was the same. Skipping."
#Comment this out to force population of iptables
exit 0
else
echo "IP was new."
echo $DYNIP > $REMEMBERFILE
fi
#----
IPT=/sbin/iptables
$IPT -t nat -F
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPT -t nat -A PREROUTING --destination $LOCALLISTENIP -p tcp --dport
$LOCALLISTENPORT -j DNAT --to-destination $DYNIP:$SENDTOPORT
$IPT -t nat -A POSTROUTING -j MASQUERADE
# Check
# $IPT -t nat -L
--------------------
------------------------------------------------------------------------
maweber's Profile: http://forums.slimdevices.com/member.php?userid=64980
View this thread: http://forums.slimdevices.com/showthread.php?t=97803
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix