Skip to main content
added 73 characters in body
Source Link
symcbean
  • 6.4k
  • 4
  • 32
  • 48

You didn't say which version of Ubuntu you are using on the client.

IIRC, recent Ubuntu's use dhclient to setup the IP address on your computer - this can perform actions (run scripts) when it exits. Just add a script in /etc/dhclient/dhclient-exit-hooks.d (check your local man page). Bear in mind that these will likely be invoked even when your existing IP lease is renewed (i.e. may fire in the absence of a network change). Have your script run a killall -HUP ssh if the IP address has changed.

Alternatively (or in addition) set a serverAliveInterval in the ssh config for this connection - this will test the connection at the speciied interval and terminate it if not working.

You didn't say which version of Ubuntu you are using on the client.

IIRC, recent Ubuntu's use dhclient to setup the IP address on your computer - this can perform actions (run scripts) when it exits. Just add a script in /etc/dhclient/dhclient-exit-hooks.d (check your local man page). Bear in mind that these will likely be invoked even when your existing IP lease is renewed (i.e. may fire in the absence of a network change).

Alternatively (or in addition) set a serverAliveInterval in the ssh config for this connection - this will test the connection at the speciied interval and terminate it if not working.

You didn't say which version of Ubuntu you are using on the client.

IIRC, recent Ubuntu's use dhclient to setup the IP address on your computer - this can perform actions (run scripts) when it exits. Just add a script in /etc/dhclient/dhclient-exit-hooks.d (check your local man page). Bear in mind that these will likely be invoked even when your existing IP lease is renewed (i.e. may fire in the absence of a network change). Have your script run a killall -HUP ssh if the IP address has changed.

Alternatively (or in addition) set a serverAliveInterval in the ssh config for this connection - this will test the connection at the speciied interval and terminate it if not working.

Source Link
symcbean
  • 6.4k
  • 4
  • 32
  • 48

You didn't say which version of Ubuntu you are using on the client.

IIRC, recent Ubuntu's use dhclient to setup the IP address on your computer - this can perform actions (run scripts) when it exits. Just add a script in /etc/dhclient/dhclient-exit-hooks.d (check your local man page). Bear in mind that these will likely be invoked even when your existing IP lease is renewed (i.e. may fire in the absence of a network change).

Alternatively (or in addition) set a serverAliveInterval in the ssh config for this connection - this will test the connection at the speciied interval and terminate it if not working.