Looking for a method that will completely smash the IP stack

Looking for a method that will completely smash the IP stack

Postby wuzamarine » Tue Sep 06, 2016 12:38 pm

I presently have a PHP script that must be ported to a different language do to a this restriction I found. Looking at Python?

I need to change my ip inside of a running script in order to solve an anomaly. This should be very straight forward using cURL

curl_setopt($ch, CURLOPT_INTERFACE, $interfaceip);

but cURL will only change the IP address from 'sub interface' to -> default. Once it reaches default, there is no way to change that IP again (it locks in place).

This is a bad thing. I need the IP address to go back and forth every 2 hours between 2 IPs.

Research into the issue indicated that something 'possibly' in the kernel is blocking this IP swap away from the <- default interface.

I was able to find a workaround by throwing the PHP script executable into a BASH script and 'that' completely breaks the connection and does a full reset, allowing my IP change at will. This 'solves my one issue' of swapping IP off the default, but creates many more.


for i in {1..1000000}; do php56 junior.000.023.php; done

But this is a really dirty hack and not an acceptable solution for the long term.

Does Python have a method that will completely break an IP connection, allowing an IP switch 'from default interface' in an actively running script, allowing me to bypass this ip rotation restriction?.

i.e. breaking/clearing completely the interface connection in a script, but without the script restart?

php code: http://stackoverflow.com/questions/3931 ... rfaces-php
Last edited by Yoriz on Tue Sep 06, 2016 1:35 pm, edited 1 time in total.
Reason: First post lock.
Posts: 1
Joined: Tue Sep 06, 2016 12:36 pm

Re: Looking for a method that will completely smash the IP s

Postby nilamo » Tue Sep 06, 2016 5:39 pm

How's this look? wrote:
Code: Select all
>>> import socket, struct, fcntl
>>> SIOCSIFADDR = 0x8916
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> def setIpAddr(iface, ip):
...     bin_ip = socket.inet_aton(ip)
...     ifreq = struct.pack('16sH2s4s8s', iface, socket.AF_INET, '\x00'*2, bin_ip, '\x00'*8)
...     fcntl.ioctl(sock, SIOCSIFADDR, ifreq)
>>> setIpAddr('em1', '')
This forum is shutting down. Future discussion should take place at http://python-forum.io
User avatar
Posts: 87
Joined: Thu Jul 21, 2016 8:00 pm
Location: Michigan

Return to Networking

Who is online

Users browsing this forum: No registered users and 2 guests