0

I've a Debian server running with some static IPs and a public IP, all provided by the same ISP on a FTTO connection.

Now I've noticed if I unplug the cable between the server and the ISP ONT/ONU and reconnect it my machine still has the same public dynamic IPv4. To get a new dynamic IP I need to a) reboot the machine or b) run dhclient -r eth0 and dhclient eth0.

My question: is it possible to reboot the machine and keep the same IP? In the same fashion as the unplug / replug network cable? How can I tell the system to reuse the last IP/Gateway it got instated going out and issue a DHCP request? And if the network doesn't work then as for a new IP?

Thank you.

TCB13
  • 1,166
  • 1
  • 14
  • 34
  • 2
    I would suspect that during shutdown or reboot, the scripts that get executed are cleanly shutting down the interface, probably issuing a DHCPRELEASE as part of the process. You may need to edit your networking init script to change or skip this behavior. – guzzijason Sep 08 '18 at 21:45
  • @guzzijason but whenever it boot again won't it run again `dhclient eth0` when the interface is being brought up? How can I keep the last IP/gateway info? Do I need to manually script the network up operation (add the last known IP etc) or there is something already built in for this? – TCB13 Sep 09 '18 at 10:21
  • 1
    Yes, the client will always look to the DHCP server on boot. But if you did not do a DHCPRELEASE on shutdown, and the lease is still valid, the server will usually issue the same address back. There is no guarantee, however; much of this is dependent on DHCP server behavior, which I'm assuming you do no control. If you are on a DHCP network, you cannot avoid this behavior. The best you can do is to not release your IP on shutdown, and _hope_ you get the same IP back again. For more info, I recommend reading the client-server section of RFC 2131: https://tools.ietf.org/html/rfc2131#section-3.1 – guzzijason Sep 09 '18 at 22:05
  • @guzzijason many thanks for the answer I'll run some testing on this. – TCB13 Sep 10 '18 at 10:06

0 Answers0