in reply to How to modify source ip address during connection to DB via DBI

What corion said, some info on that MySQL multihomed source IP, so in your DBD docs look for keywords: LocalAddr bind address
  • Comment on Re: How to modify source ip address during connection to DB via DBI ( LocalAddr bind address)

Replies are listed 'Best First'.
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
    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: $!";

      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 ?