Skip to content

Instantly share code, notes, and snippets.



Created May 4, 2018
What would you like to do?
proxy multicast from one interface to another (node.js)
// proxies from eth0 wlan0
var dgram = require('dgram')
var os = require('os')
var socket = dgram.createSocket({ type: 'udp4', reuseAddr: true })
socket.bind(5004, function () {
socket.addMembership('', getIpForInterface('eth0'))
var proxy = dgram.createSocket({type: 'udp4', reuseAddr: true})
proxy.bind(6666, '', function () {
proxy.addMembership('', '')
socket.on('message', function (m) {
if (!m.length) return
proxy.send(m, 0, m.length, '6666', '', function (err) {
if (err) throw err
function getIpForInterface (ifname) {
return os.networkInterfaces()[ifname].reduce(function (i, j) {
if ( === 'IPv4') return i
return j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.