evrenerten

Q: I need Renew DHCP Lease Script

Hi,

 

I need renew DHCP lease script for terminal.

And it must be repeat every seconds.

MacBook Pro (Retina, 15-inch, Mid 2015)

Posted on Sep 10, 2016 2:23 PM

Close

Q: I need Renew DHCP Lease Script

  • All replies
  • Helpful answers

  • by Drew Reece,

    Drew Reece Drew Reece Sep 10, 2016 2:43 PM in response to evrenerten
    Level 5 (7,490 points)
    Notebooks
    Sep 10, 2016 2:43 PM in response to evrenerten

    Um, why?

    You can probably send the relevant packets if you need to do so but you may be going about something the wrong way.

     

    netcat may construct whatever packets you like do it assuming you can concoct the relevant arguments…

    https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPag es/man1/nc.1.html

     

    Otherwise consider putting an interface down/up via networksetup, that should handle renewing a lease but I doubt you will force it to run every second - DHCP clients should wait for a reply & they generally wait a random period before giving eventually up, a second is not long enough to allow for other devices to talk on the wire.

     

    Explain what your aim is or what you need to solve & you may get better help finding an appropriate solution.

  • by evrenerten,

    evrenerten evrenerten Sep 10, 2016 2:59 PM in response to Drew Reece
    Level 1 (4 points)
    Desktops
    Sep 10, 2016 2:59 PM in response to Drew Reece

    my conneciton is drop down(wi-fi symbol is normal) until i click "renew dhcp lease" button.

    i want to type a command in terminan for this problem.

  • by Drew Reece,

    Drew Reece Drew Reece Sep 10, 2016 4:27 PM in response to evrenerten
    Level 5 (7,490 points)
    Notebooks
    Sep 10, 2016 4:27 PM in response to evrenerten

    You'd be better off fixing why the wifi is dropping it's lease (if that is the problem).

     

    Simply trying to reconnect every second (or every few seconds) won't make your networking work much better. Either you router is out of range/ faulty or incorrectly setup or your wifi card is faulty, incorrectly setup or being effected by software.

     

    If you must use Terminal read the networksetup manual, it can put an interface down & up, causing it to redo it's initialisation.

    https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPag es/man8/networksetup.8.html

    Or use 'man networksetup' to view the commands for the installed version in Terminal.

     

    I think it would be wiser to create a new topic explaining the symptoms of the wifi issue & all of your hardware/ software versions, others here will try to help you diagnose the fault if you are willing to ask a question without assuming you already have the answer.

  • by evrenerten,

    evrenerten evrenerten Sep 12, 2016 3:11 AM in response to Drew Reece
    Level 1 (4 points)
    Desktops
    Sep 12, 2016 3:11 AM in response to Drew Reece

    thnak u bot i want to repeat this code.

  • by Drew Reece,

    Drew Reece Drew Reece Sep 12, 2016 6:05 AM in response to evrenerten
    Level 5 (7,490 points)
    Notebooks
    Sep 12, 2016 6:05 AM in response to evrenerten

    evrenerten wrote:

     

    thnak u bot i want to repeat this code.

    So put it in a script & trigger it via cron, launchd or even via an Applescript alarm in Calendars.

     

    I'm not going to help you with any of those because you are choosing to fix the symptoms & not address the problem. As I already stated you need to ask for help fixing your connection, not try to work around it.

    It may be that your hardware is broken, your software needs a reinstall or maybe you have misconfigured devices. This situation is not normal & your idea on how to fix it is very fragile.