When using the Shoutcast2 yellowpages there is a really annoying issue that it always uses the default IP the system uses for an outgoing conection to register itself even if the server is configured to listen on a different ip - I guess I don't need to mention that this makes no sense and the YP system unusable. Marking all other IPs of the systems as deprecated is not an option; I don't want the stream IP to be the default IP for other outgoing connections.

So what I'm looking for is a way to make those connections (always to yp.shoutcast.com:80) use a certain source IP address. An existing tool would be perfect but a solution that requires not-too-much coding would be fine, too. I also have root access on the machine so iptables-based solutions would be even better.

2 Answers 2


iptables can do this easily with the SNAT target:

iptables -t nat -A POSTROUTING -j SNAT \
    -o eth0 -p tcp --dport 80 --destination yp.shoutcast.com \
    --to-source $STREAM_IP
  • On a side-note: If anyone plans to use this for the same reason I do: Don't match by --destination, use the owner/uid match instead. The YP host is round-robin-ish and thus you'd need to create rule for all those ips. Oct 2, 2012 at 11:40
  • Using the name will match all IPs returned by DNS. And usually something binding to "the wrong IP" because the routing table is improperly configured. If I could see it I could probably tell you what's wrong.
    – bahamat
    Oct 2, 2012 at 16:37
  • The DNS returns only one ip; they round-robined the NS records. Oct 2, 2012 at 16:58
ip route add dev eth0 src $SRC_ADDR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.