# Short DHCP lease causes VPN to lose connection

## haarp

Hey.

My uni sets internet access up by providing unencrypted WLAN, but connecting to their VPN is necessary (PPTP). IPs are assigned via DHCP by the VPN, static is _not_ possible.

My problem is that the lease for DHCP expires after 20 minutes, causing the dhcpcd to renegotiate after 10 minutes. I lose my IP after 10 minutes and get a new one, causing the VPN to fail and forcing me to reconnect. Every 10 minutes.  :Confused: 

Any idea how to fix this? I know its possible to keep your IP ("extend" the lease) instead of renegotiation, but how do I do that? I'm running dhcpcd-5.2.8.

----------

## TJNII

Try the -l option:

 *dhcpcd man page wrote:*   

> 
> 
> -l <leasetime> 
> 
> Specifies (in seconds) the recommended lease time to the server. (Note that the server can override this value if it sees fit). This value is used in the DHCP_DISCOVER message. The default is infinite (0xffffffff).
> ...

 

Frankly, I'd call your IT guy and complain about it.  20 minutes sounds like a testing value that never got reset.

[EDIT]

As I think about it, there is something else going on here.  You shouldn't lose your IP, dhcpcd should renew it automatically.  This should all happen transparently underneath you.  I'd sniff the traffic to see if dhcpcd is trying to renew the lease and if the server is ACK or NAKing it.

[/edit]

----------

## haarp

Mhh. It appears they they fixed their DHCP server over the weekend. I now get to keep my IP.

```
Nov  2 10:03:28 marauder dhcpcd[6487]: wlan0: renewing lease of 192.168.42.246

Nov  2 10:03:28 marauder dhcpcd[6487]: wlan0: acknowledged 192.168.42.246 from 192.168.42.3

Nov  2 10:03:28 marauder dhcpcd[6487]: wlan0: leased 192.168.42.246 for 1200 seconds

```

The VPN connection however still drops for no apparent reason. There's no console log by pptp/pppd, it just doesn't work anymore. When I reconnect pppd manually, I am assigned a new VPN IP (WLAN IP stays the same):

```
Nov  2 10:15:18 marauder pppd[13638]: pppd 2.4.5 started by root, uid 0

Nov  2 10:15:18 marauder pppd[13638]: Using interface ppp0

Nov  2 10:15:18 marauder pppd[13638]: Connect: ppp0 <--> /dev/pts/0

Nov  2 10:15:18 marauder pptp[13639]: anon log[main:pptp.c:310]: The synchronous pptp option is NOT activated

Nov  2 10:15:18 marauder pptp[13646]: anon log[ctrlp_rep:pptp_ctrl.c:251]: Sent control packet type is 1 'Start-Control-Connection-Request'

Nov  2 10:15:18 marauder pptp[13646]: anon log[ctrlp_disp:pptp_ctrl.c:739]: Received Start Control Connection Reply

Nov  2 10:15:18 marauder pptp[13646]: anon log[ctrlp_disp:pptp_ctrl.c:773]: Client connection established.

Nov  2 10:15:19 marauder pptp[13646]: anon log[ctrlp_rep:pptp_ctrl.c:251]: Sent control packet type is 7 'Outgoing-Call-Request'

Nov  2 10:15:19 marauder pptp[13646]: anon log[ctrlp_disp:pptp_ctrl.c:858]: Received Outgoing Call Reply.

Nov  2 10:15:19 marauder pptp[13646]: anon log[ctrlp_disp:pptp_ctrl.c:897]: Outgoing call established (call ID 0, peer's call ID 32640).

Nov  2 10:15:20 marauder pppd[13638]: CHAP authentication succeeded

Nov  2 10:15:20 marauder pppd[13638]: local  IP address xxx.xxx.xxx.xxx

Nov  2 10:15:20 marauder pppd[13638]: remote IP address xxx.xxx.xxx.xxx

Nov  2 10:15:20 marauder pppd[13638]: primary   DNS address xxx.xxx.xxx.xxx

Nov  2 10:15:20 marauder pppd[13638]: secondary DNS address xxx.xxx.xxx.xxx

```

"local IP address" is the part that changes.Last edited by haarp on Mon Nov 08, 2010 10:41 am; edited 1 time in total

----------

## haarp

no ideas?

----------

## depontius

I run a short lease on my home dhcp server - actually right in the 20 minute ballpark, too.  I've also used several different VPNs to contact my place of work, and never had a dhcp-induced fail in the VPN itself.  The issue I have had comes when I try to assign the VPN hostname to my machine, so it appears to be fully "inside" my employer's network.  (Required by some of the software I need to run.)  Then at the next lease time that name got overwritten with the dhcp-granted hostname from my LAN.  I've since scripted that problem away.

----------

## dimaq

[quote="depontius"]I run a short lease on my home dhcp server - actually right in the 20 minute ballpark, too.  I've also used several different VPNs to contact my place of work, and never had a dhcp-induced fail in the VPN itself.  The issue I have had comes when I try to assign the VPN hostname to my machine, so it appears to be fully "inside" my employer's network.  (Required by some of the software I need to run.)  Then at the next lease time that name got overwritten with the dhcp-granted hostname from my LAN.  I've since scripted that problem away.[/quote]

This sounds like a valid explanation - 2 dhcp's (wlan and vpn) conflict setting haarp's laptop hostname, default route, dns server, etc.

----------

