Changing / changing the IP address for testing on the local machine

I am trying to limit traffic to my site so that people trying to screen massive amounts of data will be blocked after a while. I have to do this based on the IP addresses of incoming requests. I suppose I have functionality restricting IP addresses, but I don’t understand how I can test it. I need to change my IP address many times in order to simulate actual traffic. I also need to test> 20 different IP addresses, so a proxy solution will not work for each of them.

I am testing the code on my local machine (running Ubuntu), so I can change the settings of my server (Apache) if I need this test.

I am behind the corporate network, so I can’t change the MAC address / ARP settings to “reassign” the new IP address. I was hoping for something like localhost IP-change, so I could take advantage of the fact that the server and client were the same machines.

In addition, I tried to avoid changing the code before deploying it to production servers, but this might be the best way to do this.

How can I customize this?

+3
source share
7 answers

Well, what you can do, instead of really checking the IP, do something like this:

$ip = '1337.1337.1337.1337';

Instead:

$ip = $_SERVER['REMOTE_ADDR']

And then keep doing your validation IP code.

So, when you're done, you can make your $ ip variable code like this:

//$ip = '1337.1337.1337.1337';
$ip = $_SERVER['REMOTE_ADDR']

, " "

EDIT:

IP:

$ips = Array('192.168.1.220', '120.843.592.86', '256.865.463.563');
$ip = $ips[rand(1,count($ips)-1)];
+5

, linux:

ifconfig eth0: 0 127.0.0.2
ifconfig eth0: 1 127.0.0.3
.. ( )

, apache ips, 0.0.0.0 ( ), IP-.

ips, , .

, .

+1

. imo - ARP, IP-, , MAC- . , src IP-, HTTP-, . .

0

, , , MAC-, IP-, . MAC IP. ubuntu, "macchanger", ( "-r" ), . .

sudo macchanger -r eth0

, . , " ".

0

( corp border, SW ). , , . - -, . , IP. , , , , , sw, , .

0

, , , tcpdump/libpcap, winpcap . , , , , / , ( ).

0

rand (0,255) concat string IP. , IP-

0

Source: https://habr.com/ru/post/1709137/


All Articles