Hello Folks
i have a sever with about 1000 ip addresses
and i want to check the external ip address using different source ip for each curl command .
in linux bash i can do that using :
curl --interface 1.1.1.1 ifconfig.io --max-time 2
curl --interface 2.2.2.2 ifconfig.io --max-time 2
above result of bash is only 1 line with ip
but in python the result of curl is an html full content , so not sure how to let pycurl be as bash curl .
also i googled a lot couldnt find a way to inject source ip in python for each curl request .
import pycurl
from StringIO import StringIO
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://ifconfig.io/')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)
above is ok , but as i said it has two issues :
1- result is full html page not as linux curl
2- i cant know where to put option as source ip address as my server is getting many ips
hopefully help me out !
thanks
i have a sever with about 1000 ip addresses
and i want to check the external ip address using different source ip for each curl command .
in linux bash i can do that using :
curl --interface 1.1.1.1 ifconfig.io --max-time 2
curl --interface 2.2.2.2 ifconfig.io --max-time 2
above result of bash is only 1 line with ip
but in python the result of curl is an html full content , so not sure how to let pycurl be as bash curl .
also i googled a lot couldnt find a way to inject source ip in python for each curl request .
import pycurl
from StringIO import StringIO
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://ifconfig.io/')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)
above is ok , but as i said it has two issues :
1- result is full html page not as linux curl
2- i cant know where to put option as source ip address as my server is getting many ips
hopefully help me out !
thanks