G'Day Monks,

I have a RedHat Linux machine that has multiple virtual interfaces on one NIC. E.g., "ifconfig eth1" might produce something like this:
eth1      Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          inet addr:172.16.1.1  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72857 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22799 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:3391110 (3.2 Mb)  TX bytes:1560024 (1.4 Mb)
          Interrupt:11 Base address:0xdd80 Memory:feafd000-feafd038 

eth1:1    Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          inet addr:172.16.1.2  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72857 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22799 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:3391110 (3.2 Mb)  TX bytes:1560024 (1.4 Mb)
          Interrupt:11 Base address:0xdd80 Memory:feafd000-feafd038 

eth1:2    Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          inet addr:172.16.1.3  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72857 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22799 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:3391110 (3.2 Mb)  TX bytes:1560024 (1.4 Mb)
          Interrupt:11 Base address:0xdd80 Memory:feafd000-feafd038 

eth1:3    Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          inet addr:172.16.1.4  Bcast:172.16.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72857 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22799 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:3391110 (3.2 Mb)  TX bytes:1560024 (1.4 Mb)
          Interrupt:11 Base address:0xdd80 Memory:feafd000-feafd038 

etc, etc, etc...
I'm working on a script that uses LWP::UserAgent to fetch some stuff from another server. Is there any way I can force a given HTTP request to go out a specific virtual interface? E.g., can I force the source ip address to be 172.16.1.3 for a given request, and then have the next request come from 172.16.1.4? Or is this the sort of thing that needs to be taken care of by the OS rather than the script?

In reply to Force HTTP Requests from a Specific Interface by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.