Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How to modify source ip address during connection to DB via DBI ( LocalAddr bind address)

by perlCrazy (Monk)
on Apr 25, 2014 at 07:41 UTC ( [id://1083747]=note: print w/replies, xml ) Need Help??


in reply to Re: How to modify source ip address during connection to DB via DBI ( LocalAddr bind address)
in thread How to modify source ip address during connection to DB via DBI

Thanks for response. Looking at some other options as well. Can we change outbound network interface dynamically for specific process ? looked at use IO::Interface qw(:flags);getIng permission denied when trying to change. Is this require root permission. can we do without root, want to implement in user space.
my $s = IO::Socket::INET->new(Proto => 'udp'); my @interfaces = $s->if_list; for my $if (@interfaces) { print "interface = $if\n"; my $flags = $s->if_flags($if); print "addr = ",$s->if_addr($if),"\n", "broadcast = ",$s->if_broadcast($if),"\n", "netmask = ",$s->if_netmask($if),"\n", "dstaddr = ",$s->if_dstaddr($if),"\n", print "is running\n" if $flags & IFF_RUNNING; print "is broadcast\n" if $flags & IFF_BROADCAST; print "is loopback\n" if $flags & IFF_LOOPBACK; print "is promiscuous\n" if $flags & IFF_PROMISC; print "is multicast\n" if $flags & IFF_MULTICAST; print "is notrailers\n" if $flags & IFF_NOTRAILERS; print "is noarp\n" if $flags & IFF_NOARP; } my $interface = $s->addr_to_interface('127.0.0.1'); # my $oldaddr = $s->if_addr('eth0'); $s->if_addr('lo','X.X.X.X') || die "couldn't set address: $!";
  • Comment on Re^2: How to modify source ip address during connection to DB via DBI ( LocalAddr bind address)
  • Download Code

Replies are listed 'Best First'.
Re^3: How to modify source ip address during connection to DB via DBI ( LocalAddr bind address)
by Anonymous Monk on Apr 25, 2014 at 07:46 UTC

    Yeah, this enters the realm of system programming ... firewalls and things like that ... its frequently common for linux and alikes to restrict socket operations for regular users

    Also IO::Interface tells you the new/better interface is IO::Interface::Simple

      Actually it lo:1 is already set. How we can dynamically change outbound traffic for that process.
      example: have one perl program, using dbi->connect() method for connection to RDBMS. once connection gets established if check incoming connection on db host,it always sees real host ip address. my requirement is to change the routing via lo:1 dynamically in program so that it will see vip ip address. any possibility ?
        through the magic that is systems programming :) translated, I don't know (ie google it)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1083747]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found