secondary IP

Status
Not open for further replies.

lightmaria

Active Member
40
2009
0
0
Dear,
I had a server come with 2 IPs, i want to use curl --interface for using secondary IP on my app, but it only show the main IP.

Code:
[root@sv~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:9C:02:AA:3C:18
          inet addr:[B]xxx.xxx.xxx.79[/B]  Bcast:xxx.xxx.xxx.127  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:499068925 errors:0 dropped:0 overruns:0 frame:0
          TX packets:386569166 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:509301350194 (474.3 GiB)  TX bytes:476849387728 (444.1 GiB)
          Interrupt:16 Memory:fbee0000-fbf00000

eth0:0    Link encap:Ethernet  HWaddr 00:9C:02:AA:3C:18
          inet addr:[B]xxx.xxx.xxx.105[/B]  Bcast:xxx.xxx.xxx.127  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:16 Memory:fbee0000-fbf00000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:2832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2832 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:199706 (195.0 KiB)  TX bytes:199706 (195.0 KiB)
Code:
[root@sv~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xxx.xxx.xxx.96   0.0.0.0         255.255.255.224 U     0      0        0 eth0
xxx.xxx.xxx.64   0.0.0.0         255.255.255.192 U     0      0        0 eth0
xxx.xxx.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         xxx.xxx.xxx.126  0.0.0.0         UG    0      0        0 eth0
Code:
[root@sv~]# curl -v --interface [B]xxx.xxx.xxx.79[/B] ifconfig.co
* About to connect() to ifconfig.co port 80 (#0)
*   Trying 188.113.88.193... Name '[B]xxx.xxx.xxx.79[/B]' family 2 resolved to '[B]xxx.xxx.xxx.79[/B]' family 2
* Local port: 0
* connected
* Connected to ifconfig.co (188.113.88.193) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: ifconfig.co
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 30 Oct 2015 01:57:44 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 14
< Connection: keep-alive
<
[B]xxx.xxx.xxx.79[/B]
* Connection #0 to host ifconfig.co left intact
* Closing connection #0
Code:
[root@sv ~]# curl -v --interface[B] xxx.xxx.xxx.105[/B] ifconfig.co
* About to connect() to ifconfig.co port 80 (#0)
*   Trying 188.113.88.193... Name '[B]xxx.xxx.xxx.105[/B]' family 2 resolved to '[B]xxx.xxx.xxx.105[/B]' family 2
* Local port: 0
* connected
* Connected to ifconfig.co (188.113.88.193) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: ifconfig.co
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 30 Oct 2015 01:59:51 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 14
< Connection: keep-alive
<
[B]xxx.xxx.xxx.79[/B]
* Connection #0 to host ifconfig.co left intact
* Closing connection #0
Thank you
 
Status
Not open for further replies.
Back
Top