How to change IP address via cocoa program/ other program

Discussion in 'Mac Programming' started by KenLin, Jul 3, 2007.

  1. KenLin
    Expand Collapse
    macrumors newbie

    Joined:
    Jul 3, 2007
    #1
    Dear All,
    I want to change IP address via cocoa's API or other function.
    Is anyone knows how to change IP in program?

    Thanks!
    Ken Lin in trouble :apple:
     
  2. janey
    Expand Collapse
    macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #2
    and why would you need to change an IP address?
     
  3. KenLin
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Jul 3, 2007
    #3
    Dear janey:
    I want to write a program to change IP easier via cocoa.

    Thanks,
    Ken
     
  4. janey
    Expand Collapse
    macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #4
    Dear Ken,

    My question is asking you why one would want to change an IP address in such a manner when there are so many things that factor into this that the end user does not have control over?

    Thanks,
    Jane
     
  5. KenLin
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Jul 3, 2007
    #5
    Dear Ken,

    My question is asking you why one would want to change an IP address in such a manner when there are so many things that factor into this that the end user does not have control over?

    Thanks,
    Jane
    _______
    Dear Jane:
    Because i want to write a wireless dongle program, and i need to change / specify dongle's host IP address.

    Thanks
    Ken
     
  6. blaster_boy
    Expand Collapse
    macrumors 6502

    blaster_boy

    Joined:
    Jan 31, 2004
    Location:
    Belgium
    #6
    You could always do a shell out from your program to launch ifconfig with the required settings to change the ip address.
     
  7. lancestraz
    Expand Collapse
    macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #7
    You can do this in Terminal.
    Code:
    sudo ifconfig en1 inet 192.168.0.1
    And I imagine you can run a shell script via cocoa.
     
  8. KenLin
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Jul 3, 2007
    #8
    Thanks: Jane, blaster_boy & lancestraz:

    Yes, shell script can work.
    Do u have any other method to change IP address? like API or other functions?

    Ken
     
  9. Eraserhead
    Expand Collapse
    macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #9
    Btw how do you do that?
     
  10. robbieduncan
    Expand Collapse
    Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #10
    NSTask
     
  11. Eraserhead
    Expand Collapse
    macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #11
    Thanks :), not knowing this has led me to go via Applescript to do it :eek:, though it is a one-off usage so it's not a big deal.
     

Share This Page