Jump to content
Sign in to follow this  
AoRaToS

Ip question

Recommended Posts

AoRaToS

I would like to know why when I'm connected to a network @IPAddress1 is it's IP and if another network adapter becomes enabled and connects it's IP takes the place of @IPAddress1 and the old @IPAddress1 shifts to @IPAddress2

I mean, it's weird...

It would be better if any new connection took the next macro:

so instead of

newaddress -> @IPAddress1

@IPAddress1->@IPAddress2

have

@IPAddress1

newaddress->@IPAddress2

Ofcourse I think it may go deeper and it's not possible to enumerate the connections and add up??

Or maybe it's more functional to always know that the new connection has @IPAddress1?

What I suggest seems more logical to me, can someone tell me the reason that this happens in the first place?


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
BinaryBrother

I'm not sure what your testing against, but I was always under the impression that the @IPAddress macro tried to display the NIC IP's in accordance to rank, or better yet, priority... Well, that's not a good way to explain it... but I think you get what I mean...

Is the adapter you are plugging in taking priority on the system? Is it the one that is wanting to handle the main connections now?

For example, you can have 2 wireless NICs, only one is going to be the dominant one, and I've always thought that the first one plugged in was the master, and would stay that way if no connectivity issues arose, yesterday when I plugged in my Linksys wireless NIC, it jumped priority over my Belkin NIC, meaning that @IPAddress1 was now the Linksys, and @IPAddress2 was the Belkin even though the Belkin was plugged in first?

Hope that helps? x.x

EDIT: And by priority I mean all my internet traffic was now routing through the Linksys...

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
AoRaToS

I've tested it quite a bit, at work I'm on a LAN, if I check, @IPAddress1 of course has the correct IP 172.15.110.34 let's say, if I then connect my usb wireless NIC it connects to a wireless network and has IP 192.168.2.4, that becomes @IPAddress1 and 172.15.110.34 becomes @IPAddress2 instead of @IPAddress2 just becoming 192.168.0.4.

Same happens here at home, my IP is 192.168.0.2, when I connect to a VPN I get one more IP and the same happens...

SO it is a fact, it happens to you also, but isn't it weird that it's like that?The first one should probably keep on as it is and no changes have to happen to it, that ruins a script that is based on @IPAddress macro and you have to check for network changes to fix it the script I guess...


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
blakel

Here are some functions that I just finished writing and have not tested them, but it may be able to help you with keeping track of each particular NIC.

Global $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")

Func GetNICIndex()
Local $c = 0
Local $nis = ""
 Local $colItems = $objWMIService.ExecQuery("SELECT Index FROM Win32_NetworkAdapter WHERE Manufacturer <> 'Microsoft' AND MACAddress <> '' AND AdapterType LIKE 'ethernet%'", "WQL",0x10 + 0x20)
 If IsObj($colItems) Then
  For $objItem In $colItems 
   $nis &= $objItem.Index & "|"
  Next
  Return StringSplit(StringTrimRight($nis,1),"|",2)
 EndIf
 Return 0
EndFunc

Func GetNICName($index)
 Local $colItems = $objWMIService.ExecQuery("SELECT NetConnectionID FROM Win32_NetworkAdapter WHERE Index = " & $index, "WQL",0x10 + 0x20)
 If IsObj($colItems) Then
  For $objItem In $colItems 
   Return StringStripWS($objItem.NetConnectionID,3)
  Next
 EndIf
 Return 0
EndFunc

Func GetNICIPAdds($index)
 Local $colItems = $objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE Index = " & $index, "WQL",0x10 + 0x20)
 If IsObj($colItems) Then
  For $objItem In $colItems
   Return $objItem.IPAddress
  Next
 EndIf
 Return -1
EndFunc

Please note, GetNICIndex and GetNICIPAdds both return arrays. I have [obviously] not put in error conditions yet.

Edited by blakel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.