Date: Thu, 28 Aug 2008 21:28:52 +0200 From: =?windows-1252?Q?Nejc_=8Akoberne?= <nejc@skoberne.net> To: Chuck Swiger <cswiger@mac.com> Cc: User Questions <freebsd-questions@freebsd.org> Subject: Re: Proxying broadcasts? SOLVED Message-ID: <48B6FC74.2010605@skoberne.net> In-Reply-To: <D36F6167-6C2A-4BF9-BDD5-BBF046F1844E@mac.com> References: <48B5CB70.9080900@skoberne.net> <D36F6167-6C2A-4BF9-BDD5-BBF046F1844E@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hey,
> The simple answer is no: if you want subnet-local broadcast traffic to
> be received, then your DB servers and your clients need to be on the
> same subnet. Routers are designed and required to not propagate
> broadcast traffic, although you could switch to doing bridging rather
> than routing. Or, you could set up Sybase's SQL.INI to list all of the
> databases you care about, if I recall correctly...
Actually, a little perl script (running daemonized on the firewall) for
each of the USERS networks solved my problem. It is somewhat ugly, but it
works.
-------------------------------------------------------------------------
#!/usr/local/bin/perl -w
# syproxy - Sybase broadcast proxy
use File::Basename;
use Fcntl qw(LOCK_EX LOCK_NB);
use IO::Socket;
use strict;
use Net::RawIP;
### Configuration
# Destination IP (broadcast) of the servers network
my $DESTINATION = "192.168.1.255";
# Sybase port
my $PORT = 2638;
# Broadcast address of the USERS network
my $LISTEN = "192.168.3.255";
# Packet length
my $MAXLEN = 1024;
my $sport;
my $source;
my $ipaddr;
my $data;
my $progname = basename($0);
# Selflock
open(SELFLOCK, "<$0") or die("Couldn't open $0: $!\n");
flock(SELFLOCK, LOCK_EX | LOCK_NB) or die("Aborting: another $progname is already running\n");
chdir('/');
# Double-fork to avoid leaving a zombie process behind:
exit if (fork());
exit if (fork());
sleep 1 until getppid() == 1;
# Create the socket
my $recv_socket = IO::Socket::INET->new(
Proto => 'udp',
LocalPort => $PORT,
LocalAddr => $LISTEN,
Broadcast => 1,
ReuseAddr => 1
) or die "Creating socket: $!\n";
while (1) {
# Wait for packets
$recv_socket->recv($data, $MAXLEN);
# Get the sender address
($sport, $ipaddr) = unpack_sockaddr_in($recv_socket->peername);
$source = inet_ntoa($ipaddr);
# Construct the packet
my $send_socket = new Net::RawIP({udp =>{}});
$send_socket->set({ip => {saddr => $source , daddr => $DESTINATION,
tos => 22}, udp => {source => $sport,
dest => $PORT, data => $data }});
# Send the spoofed packet
$send_socket->send;
}
-------------------------------------------------------------------------
Thanks,
Nejc
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48B6FC74.2010605>
