C # - one MAC address, multiple source IP addresses

I am trying to write a Windows application that will generate traffic via an ethernet link from a PC.

I want to use webBrowser controls to continuously pull web pages to generate traffic.

In this case, I want each webBrowser control to be associated with a unique source IP address. Two questions:

  • Is it possible for one PC (i.e. one MAC address) to have multiple simultaneous IP addresses?

  • If the answer to question No. 1 is yes, is it easier to use DHCP requests in C # application code to get additional IP addresses, or is it easier to just set up static IP addresses?

  • How to get the IP addresses obtained in step 2 in C # code (just give me a general idea).

Thanks Steve

+4
source share
1 answer

Yes, it is absolutely possible for one network adapter to have multiple IP addresses. However, I would suggest configuring them manually (on Windows, you can add additional IP addresses through the advanced TCP / IP settings in the IPv4 properties of the network connection).

From the point of view of using these IP addresses, from the code it is relatively simple, you can just bind to a specific local IP address (using TcpClient constructor TcpClient(IPEndPoint localEndPoint) allows you to do this).

However, if you use a web browser control, this may be more complex, and it may not be possible to bind it to a specific local address through the public interfaces in the control.

If you don’t need any particularly advanced features, you might be more fortunate to create your own simple HTTP requests and send them to the correspondingly connected TcpClient .

Edit:

A quick search showed this answer , which may be useful as long as it still doesn’t allow you to use a graphical web browser control bound to a specific local address, it allows you to use HttpWebRequest , which will allow you to process sending more advanced web requests (cookies, compression , redirection, etc.).

+5
source

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


All Articles