Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Add Multiple IP Addresses

Add Multiple IP Addresses

Scheduled Pinned Locked Moved C#
csharp
11 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wasifmuneer
    wrote on last edited by
    #1

    I want to add ip address to my lan card by using Management class' method like GetMethodParameters("EnableStatic") ; but i am unable to assign multiple ips to my lan card is there any way to add ip address programmatic, like we use advanced tab and then ip settings tab to add another ip address, or is there any way to call net set command using C# Thanks in Advance Regards

    M realJSOPR 2 Replies Last reply
    0
    • W wasifmuneer

      I want to add ip address to my lan card by using Management class' method like GetMethodParameters("EnableStatic") ; but i am unable to assign multiple ips to my lan card is there any way to add ip address programmatic, like we use advanced tab and then ip settings tab to add another ip address, or is there any way to call net set command using C# Thanks in Advance Regards

      M Offline
      M Offline
      Michel Godfroid
      wrote on last edited by
      #2

      WHY do you want to add IP addresses? What is your purpose? Are these IP addresses yours?

      W 1 Reply Last reply
      0
      • M Michel Godfroid

        WHY do you want to add IP addresses? What is your purpose? Are these IP addresses yours?

        W Offline
        W Offline
        wasifmuneer
        wrote on last edited by
        #3

        Yes those ip addresses are of our network, basically i want to ping that ip address if no reply from ping is returned then i want to add that ip as secondary ip of my lan card, just like dhcp but i dont want to use dhcp caz i have specific ips

        M 1 Reply Last reply
        0
        • W wasifmuneer

          Yes those ip addresses are of our network, basically i want to ping that ip address if no reply from ping is returned then i want to add that ip as secondary ip of my lan card, just like dhcp but i dont want to use dhcp caz i have specific ips

          M Offline
          M Offline
          Michel Godfroid
          wrote on last edited by
          #4

          Still does not make sense. Adding an IP address to your interface brings you nothing, if the rest of the world doesn't know about it. The only situation where this could be valid is if you have a physical subnet which carries 2 or more logical subnets, where only one of them is DHCP enabled. There may also be uses if you're defining a fault tolerant cluster, where you reserve fallback addresses, but in that case you should reserve them first. In all other situations, you are going to mess up routing tables, impact your own connectivity, and generally be a nuisance to everyone on the network. Doing it programmatically only guarantees that you're ALWAYS a nuisance.

          realJSOPR 1 Reply Last reply
          0
          • W wasifmuneer

            I want to add ip address to my lan card by using Management class' method like GetMethodParameters("EnableStatic") ; but i am unable to assign multiple ips to my lan card is there any way to add ip address programmatic, like we use advanced tab and then ip settings tab to add another ip address, or is there any way to call net set command using C# Thanks in Advance Regards

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            There's a thing called DHCP. It's part of the operating system. Use it.

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            W 1 Reply Last reply
            0
            • M Michel Godfroid

              Still does not make sense. Adding an IP address to your interface brings you nothing, if the rest of the world doesn't know about it. The only situation where this could be valid is if you have a physical subnet which carries 2 or more logical subnets, where only one of them is DHCP enabled. There may also be uses if you're defining a fault tolerant cluster, where you reserve fallback addresses, but in that case you should reserve them first. In all other situations, you are going to mess up routing tables, impact your own connectivity, and generally be a nuisance to everyone on the network. Doing it programmatically only guarantees that you're ALWAYS a nuisance.

              realJSOPR Offline
              realJSOPR Offline
              realJSOP
              wrote on last edited by
              #6

              He's trying to do what DHCP does.

              .45 ACP - because shooting twice is just silly
              -----
              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

              1 Reply Last reply
              0
              • realJSOPR realJSOP

                There's a thing called DHCP. It's part of the operating system. Use it.

                .45 ACP - because shooting twice is just silly
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                W Offline
                W Offline
                wasifmuneer
                wrote on last edited by
                #7

                i have used "EnableDHCP" option but it enabled obtain ip automatically option in tcp/ip settings, but i dont need that. i need to add multiple static ips to my lan card, like DHCP do

                W 1 Reply Last reply
                0
                • W wasifmuneer

                  i have used "EnableDHCP" option but it enabled obtain ip automatically option in tcp/ip settings, but i dont need that. i need to add multiple static ips to my lan card, like DHCP do

                  W Offline
                  W Offline
                  wasifmuneer
                  wrote on last edited by
                  #8

                  i have done this by another method, i pinged my desired ip and then if that ip pinged fail, i created a batch file to process and assigned that ip to my nic. thanks for your responses, if any one among you guys get the solution to do without executing batch file means through coding. Regards

                  D 1 Reply Last reply
                  0
                  • W wasifmuneer

                    i have done this by another method, i pinged my desired ip and then if that ip pinged fail, i created a batch file to process and assigned that ip to my nic. thanks for your responses, if any one among you guys get the solution to do without executing batch file means through coding. Regards

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Yeah, but why would you even want to do this? Just pinging an IP to see if it's alive then assigning it to you LAN card gets you nothing. If you're adding IP addresses to the card that are not even part of the subnet that your machine is on just gets you wasting your time since you can't route traffic to that IP if it's not on the correct subnet.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008
                    But no longer in 2009...

                    W 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      Yeah, but why would you even want to do this? Just pinging an IP to see if it's alive then assigning it to you LAN card gets you nothing. If you're adding IP addresses to the card that are not even part of the subnet that your machine is on just gets you wasting your time since you can't route traffic to that IP if it's not on the correct subnet.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007, 2008
                      But no longer in 2009...

                      W Offline
                      W Offline
                      wasifmuneer
                      wrote on last edited by
                      #10

                      Actually the purpose to this all scenario is, we work on real time systems in which we are going to arrange high availability of system, like two main servers, two branch servers and etc, there would be only one main server and one branch server running in one time if one of the each server (either branch or main) get fails to respond to its counter part, then another (branch or main server) gets which are already powered on gets connected to its counter part. hope you could understand the scenario Regards

                      D 1 Reply Last reply
                      0
                      • W wasifmuneer

                        Actually the purpose to this all scenario is, we work on real time systems in which we are going to arrange high availability of system, like two main servers, two branch servers and etc, there would be only one main server and one branch server running in one time if one of the each server (either branch or main) get fails to respond to its counter part, then another (branch or main server) gets which are already powered on gets connected to its counter part. hope you could understand the scenario Regards

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #11

                        So basically, you're trying to kludge together a "poor mans cluster". This is not going to implement a "high availability" system. You've got a couple of problems. First, neither server is going to have an exact copy, if at all, of the data the other one has. There has to be some kind of syncing going on. There is going to be, in most cases, a substantial lag between one server storing data and the other one picking it up. Depending on the amount of data you have to sync, this can take from minutes to hours to complete 1 sync cycle. Next, what's you're polling interval going to be for pings? What's you're timeout going to be? How many pings in a row must the server not respond to before it's considered failed? What if both servers are actually running and it's just the ping that didn't come back? Now you've got two servers with the same IP's running and you'll end up with even bigger problems. Another problem is how are you going to recover the failed server once it's back up? When it comes back up, it should have it's original IP address to match it's DNS record. Now you've got 2 servers going on the same IP address and the one that hold both IP's has no way of automatically determining that the failed server is back up and running because ping's going to that address will get routed back to the "good" server without ever going down the network cable. At a certain auto manufacturer I used to work for, we did something similar. It was impossible to get the lag time down between the two servers to under 4 hours because they had to sync up hundreds of GB of data constantly. Once server always had a copy of the data that was at least 4 hours old, and probably longer. IMHO, you should be looking for an actual cluster or single IP solution depending on your requirements. Doing something like this is not scalable at all. If you added more servers, this solution cannot be expanded without rewriting the code to "steal" IP addresses.

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007, 2008
                        But no longer in 2009...

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups