charlesboyo has asked for the wisdom of the Perl Monks concerning the following question:
I recently started using the TPROXY (transparent proxy) kernel extensions that make it possible to bind to non-local IP address in Linux kernel 2.6.
A recent kernel with TPROXY support is in use and netfilter/iptables has been re-compiled with TPROXY support.
Do I need to recompile Perl as well?
#!/usr/bin/perl use strict; use Socket qw(:all); use constant SOL_IP => 0; use constant IP_FREEBIND => 15; $|++; # no buffering my $proto = getprotobyname('tcp'); socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto) or die "socket: $! +"; setsockopt( Socket_Handle, SOL_IP, IP_FREEBIND, 1) or die "setsockopt: + $!"; # set local address to a non-local address :) my $laddr = inet_aton('10.8.31.5'); bind(Socket_Handle, sockaddr_in(0,$laddr)) or die "bind: $!"; # attempt to connect to remote webserver my $port = getservbyname('http', 'tcp'); my $sin = sockaddr_in($port,inet_aton("www.google.com")); connect(Socket_Handle,$sin) or die "connect: $!";; sleep 2; close (Socket_Handle) || die "close: $!"; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I enable TPROXY in Perl?
by Illuminatus (Curate) on Apr 15, 2011 at 18:57 UTC | |
by charlesboyo (Beadle) on Apr 16, 2011 at 02:06 UTC |