Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] DHCP with OpenVPN in TAP mode #822

Closed
2 tasks done
RonNabuurs opened this issue Nov 28, 2018 · 9 comments
Closed
2 tasks done

[Feature request] DHCP with OpenVPN in TAP mode #822

RonNabuurs opened this issue Nov 28, 2018 · 9 comments

Comments

@RonNabuurs
Copy link
Contributor

RonNabuurs commented Nov 28, 2018

Prerequisites

  • Can you reproduce?
  • Are you running the latest version of SoftEtherVPN?

SoftEther version: Build from master 3842e81
Component: Server
Operating system: Ubuntu 18.04 server
Architecture: 64 bit

Description

I'm using SoftEtherVPN server as an Openvpn server. Connection with an layer 3 (tun) config works fine, but when I connect with an layer 2 (tap) config I won't get an ip address.
The server has dhcp enabled as made clear by the ip that gets leased by connection to the server with an tun config.

Expected behavior:
Get an ip lease with a tap config.

Actual behavior:
I don't get an ip.

Some relevant logs

When connecting with tun I do get an ifconfig push, but not with tap.

Log from tun config:
Wed Nov 28 12:11:08 2018 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10,topology subnet,ifconfig 192.168.30.10 255.255.255.0,dhcp-option DNS 192.168.30.1,route-gateway 192.168.30.1,redirect-gateway def1'

Log from tap config:
Wed Nov 28 11:43:56 2018 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10'

@davidebeatrici
Copy link
Member

It's the intended behavior, because the operating system is supposed to be sending a DHCP request through the virtual network interface, which is what happens on Windows.
On Linux you have to do it manually, before the client times out. You could set up a script for OpenVPN to do it automatically:

dhcp-manager.sh

#!/bin/bash

case $script_type in

up)
	echo "Requesting IP address for ${dev} from DHCP server..."
	dhclient -v "${dev}"
	;;
down)
	echo "Releasing ${dev}'s DHCP lease..."
	dhclient -r "${dev}"
	;;
esac

In OpenVPN's configuration:

up dhcp-manager.sh
down dhcp-manager.sh

@RonNabuurs
Copy link
Contributor Author

RonNabuurs commented Nov 30, 2018

Thanks for the quick reply!
Alright, after some more testing I did notice that Windows did indeed get an ip and it's only a problem on Linux.
Though when using the standard OpenVPN server (which I plan to replace with a SoftEther one), the server does send an ip to Linux and Windows without the manual dhclient call.
Maybe this could be a new feature for SoftEther? Perhaps a setting that forces the SoftEther OpenVPN server to send out dhcp leases.

@davidebeatrici
Copy link
Member

You're welcome!

The OpenVPN server acts as a DHCP server when you set the network in its configuration, otherwise it doesn't send the IP address because it isn't a DHCP client.

We can implement the feature in SoftEther VPN, with a client-side environment variable such as UV_NO_DHCP to disable it.

@davidebeatrici davidebeatrici changed the title OpenVPN doesn't get an IP when connecting with layer 2 (tap) [Feature request] DHCP with OpenVPN in TAP mode Nov 30, 2018
@davidebeatrici
Copy link
Member

The client timing out turned out to be an OpenVPN bug, we implemented a workaround in #828.

#827 implements the desired feature, however in Layer 2 mode the DHCP lease is supposed to be requested by the client and not by an intermediary entity (the VPN server).

Do you still want the feature, now that the timeout issue is not present anymore?

@RonNabuurs
Copy link
Contributor Author

That's wonderfull to hear.
I'll be able to test this on Monday. #827 seems like a great solution to our problem, so I'll test this tomorrow. And it's also great that the OpenVPN bug got fixed with #828 .
You guys are amazing 😄

@RonNabuurs
Copy link
Contributor Author

I've tested #827 and #828 and both seems to be working fine. If its up to me this feature can be merged. Again, thank you for the great work!

@davidebeatrici
Copy link
Member

You're welcome!

#827 implements the desired feature, however in Layer 2 mode the DHCP lease is supposed to be requested by the client and not by an intermediary entity (the VPN server).

We're probably not going to merge #827 for this reason, sorry.

@RonNabuurs
Copy link
Contributor Author

Alright, that totally understandable. I'll make a patch from your implementation for my own projects.

@davidebeatrici
Copy link
Member

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants