New virtual network adapters being assigned randomly [closed] - batch-file

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a setup where I clone virtual machines, therefore changing their mac addresses.
When each machine boots up, it gets assigned to a Local Area Connection x interface.
I then run a batch script that changes the IPs of the interfaces:
netsh interface ip set address name="Local Area Connection 1" static 192.168.1.50 255.255.255.0 192.168.1.254
netsh interface ip set address name="Local Area Connection 2" static 172.16.5.50 255.255.255.0 172.16.5.254
The problem is that the adapters gets assigned randomly - the first NIC sometimes gets Local Area Connection 1 and sometimes Local Area Connection 2. Therefore I can't assign the IP addresses.
The NICs are ordered correctly by their MAC addresses. I've thought about getting the MAC addresses of the two active interfaces, sort them, and find out the assigned adapter names, and only then run netsh interface ip set, however I'm not sure how can I do it.
Any ideas?

I used the getmac util to get the MAC addresses along with their assigned connection names:
getmac /V /FO LIST
There is also a solution with Powershell:
http://www.ddls.net.au/blog/2012/08/renaming-network-connections-using-powershell-and-wmi/

Related

.bat for renewing IP until it starts with certain numbers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
My ISP, unfortunately, has different routes for different IPs, so pings are drastically different as well. Can someone please help me to write a .bat which performs ipconfig /release && ipconfig /renew until IP starts with some value? (I noticed that IPs starting with 147...* have the lowest ping)
here is a powershell script that will do the job:
[string]$ip = (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
while(!$ip.StartsWith('147')){
ipconfig /release *con*
ipconfig /renew
$ip = (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
}
please put the number that you want your ip to start with inside the loop condition, it will continue to release and renew until you get an ip that starts with that number.
Well your ISP may or may not change your IP address for a while, even if it is dynamic. I can only suggest going into your router's setting and releasing your WAN IP address and renewing it or simply restarting the router.
Note : for your request ipconfig /release / renew doesn't affect your external/ ISP IP address it renews the internal IP Address.
to release and renew you're internal ip address you can run the bellow commands in powershell:
ipconfig /release *Con*
ipconfig /renew
to get your external ip address you can use powershell to invoke a web request:
[string]$ip = (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
and then you can check if that ip starts with a specific number:
if($ip.StartsWith('147')){
#some code here
}

netsh set IP address adaptor name conflict

I use the following netsh command when setting the IP address of the LAN Adaptor within a batch file.
netsh int ipv4 set address name="Local Area Connection" source=static address=10.000.0.1 mask=255.255.255.0 gateway=none
I have recently encountered an issue where the batch-file was run on a different system and this has failed to work (returning Element Not Found), I found the cause of the issue to be the adaptor was labelled 'Ethernet'.
This works fine providing the adaptor is labelled as 'Local Area Connection' and the easy fix is to rename the adaptor.
However i would like a solution where it isnt required to rename and the command works on any system irrelevant of how the LAN Adaptor is labelled on that system.
Is this possible?

receive packet from device is not working as expected [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Here is my configuration
my PC IP :192.168.1.57 subnetmask : 255.255.255.0
my device IP :73.83.1.57 subnetmask : 255.255.255.0
i am successfully able to send packet from my pc to device but not able to send packet from device to pc (have checked in wire shark but it show only PC->device packet transmission flow )
Now i have added one more IP like device ip family in PC (73.83.1.60) then successfully able to two way communication.same works in reverse order means i have set my device IP as 192.168.1.58.
So is there any rules like both IP must belongs to same IP family?
because sub net mask in both are same. so issue is IP.
Any one have idea? is it correct network behavior? can i solve it without making same IP family.?
If you are using both IPs on the same LAN they should be on the same subnet ex:
11.1.1.1/24 can ping 11.1.1.44/24 but it can't ping 11.1.2.2/24 ( different subnets)
In WAN not necessary, for example 192.168.1.1 can ping 72.1.1.1 ,, but 72.1.1.1 can't ping 192.168.1.1 because this ip is private and when it leaves the LAN it becomes real ip because of NAT (Network Address Translation)

simple server in C [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I created a simple TCP/IP server in c and it runs smoothly from my Linux machine. I can connect as localhost:80 as well as from different machines, but I obviously have to use the lab computer's IP.
My question is: how do I run a server form my own Mac OS X machine, let's say, and connect to it form outside? Not sure how to properly ask the question... how to assign a specific IP to my server? Sorry, I am still exploring this field!
Thanks!
If your local proxy or box is configured to allow entering connections, the easiest is to assign a fixed name that will be mapped to your (dynamic) IP.
There are a lot of dynamic DNS free solutions on the web (ex : http://www.no-ip.com/)
If you just want to make a one time test, you can see what IP you have with a service like this one : http://www.whatismyip.com/
All you need is a machine that has globally routable static ip address. And run your server on that machine.
Running it on your Mac laptop is okay but as you hop from one wifi network to other your server is no longer available.
Best way is to find a machine , a desktop in your lab or ar home connected to say comcast isp that has a static globally rout able ip and run your server on there.

How can I give a name to an IP address? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am developing a web app using Tomcat. I want to give a name (a domain name) like "google" to access my site.
How can I do that?
If you only want to give a fake, temporal domain name for demo purposes on your development computer, you can add a line in your hosts file (typically located in /etc/hosts in UNIX/Linux systems):
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
# My fake domain name for demo purposes
192.168.1.121 google.com
Then, when you open the 'google.com' domain name on your computer, it will redirect you to the specified IP address.
Note that this won't work if you want to access your application from other machines. You would have to make the same change in every computer's hosts file for that to happen.
And obviously, you won't be able to access the real google.com website while having that line in your hosts file.
For Windows systems, the only thing that changes is the location of the hosts file (you must be an Administrator to edit this file):
Windows XP/Vista/Windows7:
c:\windows\system32\drivers\etc\hosts
I think you need to read up on the Domain Name System (DNS). The RFC is a bit dry so maybe start with wikipedia.
Once you understand the basics it's time to purchase a domain from a registrar and set it up.
You need to register a domain name, then set up DNS records (including an A record that points the name to the IP address) on nameservers somewhere, and that IP address has to be accessible from the 'net. You may need web hosting for that, unless you have an always-on internet connection, in which case you need to configure your router to pass through port 80 traffic to the computer running the app.
There are many web hosting companies that will do the name registration and DNS setup and hosting for you if you host the site with them.
You need some hosting to get your site on the internet
You need to register a domain name and point it at your hosting
Most hosting companies provide both services, which means you don't need to worry about "HOW" you do any of this.

Resources