February 26, 2006

UDP directed broadcast helper

I wrote a little program called pbh to forward directed UDP broadcasts along. If this doesn’t quite make sense, see my last entry. Note that the script is in Python and has only been tested on Python 2.3 (FC2) and 2.4 (CentOS 4; er, I think CentOS 4 has Python 2.4). Also note that python setup.py install probably won’t do what you want; better to python setup.py bdist_rpm and install the resulting RPM. If RPM isn’t your thing, either extract (rpm2cpio dist/pbh-0.2-1.noarch.rpm | cpio -ivdm off the top of my head) or alien it. If there’s demand I can post the “binary” RPM (pbh-0.2-1.noarch.rpm) or maybe I can even be convinced to look at making the install command work correctly. I’ve done minimal testing and it seems to work; I’ll know more when the client actually starts using it with their messaging application.

A few nice things I found while building the distribution for this program. distutils isn’t horrible. Check out setup.cfg in this distribution to see how I override the defaults for the bdist_rpm command. Note, though, that when overriding the %install script for the generated RPM, it replaces (not appends!) the default script, which means your install script needs to install everything. In my case that wasn’t a problem, but I noticed there’s no way to get the name/path of the Python interpreter from inside the provided script (bdist_rpm_install in this case).

Also, I found the fedora-rpmdevtools package which includes skeletons for RPM spec files and, more importantly to this project, an initscript (/usr/share/fedora/template.init).

Comments (4)

  1. May 4, 2011
    Oliver Jackson said...

    Hi. More than five years down the track I’ve massaged your pbh.py script into firing up on Ubuntu 10.04 64bit server. It’s intended to listen for UDP directed broadcast packets from a remote desktop management app called LanSchool.

    I have the following output from a netstat –listen :
    pbh.py 3373 root 4u IPv4 9766 0t0 UDP 10.10.51.254:796

    But a bit of packet sniffing on the network shows the ubuntu machine responding to some of the packets directed at 10.10.51.254 with :
    ICMP Destination unreachable (Port unreachable).

    No rebroadcast packets are happening.

    Can you summons up the past to think of anything which might be causing this lack of functionality?

    Cheers

    Oliver

    • May 9, 2011
      darkness said...

      My first observation is that 10.10.51.254 is not a broadcast address. pbh was designed to receive directed broadcasts on one interface and then send (“spoof”) them out another interface.

      That aside, my first guess is your iptables rules are rejecting the packet.

  2. October 20, 2013
    badmax said...

    I changed the script because it did not re-send the trafic as I wanted…

    In the sender code, I changed the destination option for a target option (-t).

    Now the script work as follow:
    pbh.py -d -p -i -t