Install SoftEther VPN Server on CentOS

This is a guide for installing SoftEther VPN Server on CentOS. SoftEther VPN is a good choice for accessing your local network from a computer outside. It works much faster than other VPN services but you need a client tool for all advanced features.

Preparing

The server requirement:

  • Hardware:
    • A not so bad CPU. Intel Atom CPU is good enough.
    • 256MB RAM, 512MB will be better.
    • 2GB free disk space after OS installed.
  • CentOS
  • A Windows client for running configuration tool.

For who want to choose Ubuntu as server side: The recommended Linux for SoftEther is RHEL, Fedora and CentOS. I’ve tried to install SoftEther VPN Server on Ubuntu Server 14. Some technique problem about firewall (iptables) may occur.

For the people in China: A working VPN is required for installing SoftEther server. Some friends said the server will be blocked by GFW while installing oversea. But working with a configured SoftEther VPN Server is allowed.

For the people who need to install on Windows Azure: This server cannot support protocols other than TCP and UDP. PPTP (not supported by SoftEther either) and L2TP cannot be supported due to protocol GRE support is lacked. SSTP and SoftEther client software are supported well. And don’t forget to open the port 443 on the management webpage.

We will create a VPN server using a subnet 192.168.250.0/24. If this is not acceptable, you need to change all related IP addresses below.

The network interface name should be eth0. If not, you need to change related device name below.

CentOS environment adjusting

We need some tools to build and install SoftEther VPN Server.

First, please make sure all components are up to date.

yum update -y

Tools for building executable files are required:

yum groupinstall "Development Tools" -y

Some services for VPN clients should be installed:

yum install dhcp dnsmasq -y

Data forwarding should be enabled by set net.ipv4.ip_forward to 1 in /etc/sysctl.conf.

in file: /etc/sysctl.conf

net.ipv4.ip_forward = 1

Edit dhcpd configuration file to start dhcpd only for VPN clients. In CentOS 7, this step can be skipped.

in file: /etc/sysconfig/dhcpd

DHCPDARGS=tap_vpn

Don’t worry. The tap_vpn will be created by following steps soon.

Adjust dhcpd configuration file like this:

in file: /etc/dhcp/dhcpd.conf

option domain-name "myvpndomain.com";
option domain-name-servers 192.168.250.1, 8.8.8.8;

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.250.0 netmask 255.255.255.0 {
range 192.168.250.10 192.168.250.100;
option routers 192.168.250.1;
}

This dhcpd.conf should be edited carefully. Make sure all semicolons and quotes are written in the right position. The domain-name should be changed into your name specified. If you don’t want to change the default gateway for VPN clients, delete the option routers line. You may want to check the conf file provided by user sigma in the comment area of this article.

For CentOS 7 user: this document is prepared with iptables which is replaced by firewalld in CentOS 7 by default. You can follow this article to make the iptables back. Main commands are listed here.

yum install -y iptables-services
systemctl mask firewalld
systemctl enable iptables
systemctl stop firewalld
systemctl start iptables

If required, add these commands to the end of /etc/sysconfig/iptables to open the ports for SoftEther. You need to change the port numbers below. Each line is for one port. Lines of port 53 are for DNS. You can remove all lines with REJECT and DROP if you want to make it easier.

in file: /etc/sysconfig/iptables

-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 53 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

SoftEther VPN Server installing

First, you need to get the address for the right release. Navigate to SoftEther Download Center by your client computer, select the SoftEther VPN Server and your CPU type to get the URL of the latest release.

Download the file into your server by using wget or some other tool you like.

! For example only. You should choose the right CPU version. !

wget http://www.softether-download.com/files/softether/v4.10-9473-beta-2014.07.12-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.10-9473-beta-2014.07.12-linux-x64-64bit.tar.gz

Decompress the downloaded file by using tar.

! For example only. File name should be changed. !

tar zxvf softether-vpnserver-v4.10-9473-beta-2014.07.12-linux-x64-64bit.tar.gz

A folder named vpnserver will be created after decompressing. Let’s make the executable files and change the permissions.

cd vpnserver/
make
cd ..
mv vpnserver /usr/local
cd /usr/local/vpnserver/
chmod 600 *
chmod 700 vpnserver
chmod 700 vpncmd

By making process in current version, you need to answer 1 three times.

Check the NIC name of this server by typing ifconfig. It the name is not eth0, correct it in script below.

Create a script file named vpnserver for handling server instance start and stop.

new file: /etc/init.d/vpnserver

#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
sleep 3
ifconfig tap_vpn 192.168.250.1
iptables -t nat -A POSTROUTING -s 192.168.250.0/24 -o eth0 -j MASQUERADE
service dhcpd restart
service dnsmasq restart
;;
stop)
iptables -t nat -D POSTROUTING -s 192.168.250.0/24 -o eth0 -j MASQUERADE
$DAEMON stop
rm $LOCK
;;
restart)
iptables -t nat -D POSTROUTING -s 192.168.250.0/24 -o eth0 -j MASQUERADE
$DAEMON stop
sleep 3
$DAEMON start
sleep 3
ifconfig tap_vpn 192.168.250.1
iptables -t nat -A POSTROUTING -s 192.168.250.0/24 -o eth0 -j MASQUERADE
service dhcpd restart
service dnsmasq restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

Make sure the folder for lock is created.

mkdir /var/lock/subsys

Grant the permission of the file created.

chmod 755 /etc/init.d/vpnserver

Set vpnserver to auto start. There are two hyphens before “add”.

chkconfig --add vpnserver

Start the vpnserver.

service vpnserver start

Some errors will occur related to tap_vpn and dhcp. Don’t worry about that.

Now we set a password for remote management.

cd /usr/local/vpnserver
./vpncmd
... press 1 and press enter ...
... press 2 enters to get the prompt "VPN Server>" ...
ServerPasswordSet
exit

Let’s turn to Windows now. Don’t close the shell or reboot the server.

SoftEther VPN Remote Managing

Install SoftEther VPN Server Manager for Windows from SoftEther Download Center.

Create a new server by entering the remote server IP address.

After connected, delete the hub named DEFAULT and create a new one. Check “No Enumerate to Anonymous Users” to protect and hide your server.

Create at least one user account for the Hub created.

Click “Local Bridge Setting” button below. Select the Hub you’ve created, “Bridge with New Tap Device” and type the New Tap Device Name “vpn” (lowercase, without quotes) to create the “tap_vpn” we’ve mentioned twice above. Never use SecureNAT for this hub because it’s not compatible with bridge and sucks currently.

Now you need to go back to the server shell to reboot the whole system.

SoftEther VPN Client Optimizing

To make the VPN connection fast and stable, you may want to change some advanced settings in client side.

  • Number of TCP Connections: Set to 8 or above for broadband.
  • Set Connection Lifetime for Each TCP Connection: Check and set to 300.
  • Use Half-Duplex Mode: Check if you can.
  • Disable UDP Acceleration: Check.

Future Upgrading

When you need to update the server side, you need to:

Stop the service.

service vpnserver stop

Download the latest version of SoftEther VPN Server and build it.

wget brabrabrabra
tar zxvf brabrabrabra
cd vpnserver
make
chmod 600 *
chmod 700 vpnserver
chmod 700 vpncmd
cp -r * /usr/local/vpnserver/

And start the service again.

service vpnserver start

WDS of Windows Server 2012 R2 with Update

No matter the way you get the Windows Server 2012 R2 with Update, by fresh installing from the CD supplied by MSDN Subscription or simply upgrading by Windows Update, the WDS of this system sucks.

 

If you planned to upgrade, please remember to backup the Boot folder of WDS while using Windows Server 2012 R2 without that update. After upgrading process, you need to stop WDS service, replace the Boot folder with your backup and restart WDS.

 

The Boot folder provided with Windows Server 2012 R2 with Update or Windows 8.1 with Update, is not compatible with capture image creation. If you use the original Boot folder from Windows Server 2012 R2 with Update, or get the Boot folder upgraded by adding a boot.wim from Windows Server 2012 R2 with Update or Windows 81. with Update, it can boot but cannot support capture image any more. No matter which boot file your capture image is created based on, even you get your capture image from another server, it just cannot boot your PC for capturing. After loading finished, you will get an error in winload.exe with the status code 0xc000000f.

 

To avoid this, do NOT use the boot.wim from Windows Server 2012 R2 with Update or Windows 8.1 with Update ISO files which are provided by MSDN Subscription. And do NOT use the Boot folder provided with the WDS of Windows Server 2012 R2.

To fix this, you just need to restore the WDS Boot folder from your backup before upgrading this update. If you don’t have a backup, copy this folder from another server which is hosted by Windows Server 2012 R2 (without that Update).

 

Still don’t know the reason but it’s not suprised me that WDS is not tested well. In many versions of Windows Server, WDS cannot work well.

 

Related:

Do NOT add a boot file for WDS from Windows 6.3 with Update

Caution: Upgrading Windows to 2012 R2 may change the interface number of network interface card

Some server has specified settings wrote by command “route -p” to deal with multiple internet or intranet connections. To make it work with RRAS, the option “if <number>” must be provided with each route command.

If you’re planning to upgrade such a server to Windows Server 2012 R2, be careful, you may have to get a console connection. Through upgrading process will not failed or at least give you any warning about route settings, after it done, the interface number of NIC (network interface card) will be changed. It means you have to remove and add the related persistent routes to resume the remote connection before you can use this server again.

If you cannot get a console, you may want to disable RRAS, remove the “if <number>” parameter from the route command before upgrading.

Do NOT add a boot file for WDS from Windows 6.3 (2012R2/8.1) with Update

If you have a Windows Deployment Service (WDS for short) hosted by Windows Server 2012 R2 (w or w/o update), never try to add a boot file from Windows Server 2012 R2 with Update (MSDN CD) or Windows 8.1 with Update (MSDN CD). If you do so, all capture image, no matter which version of boot file is based on, or it’s created by this server or others, just cannot work. After the loading finished, you will get an error in winload.exe with the status code 0xc000000f.

If you have been in this jam, you have to restore the whole boot folder from the backup before you attach the new version boot files. Don’t forget to stop the WDS before you replace the folder. Delete the new boot file only won’t work.


Update: There is another way to fix the broken capture image file directly. But you have to do that for every capture file. http://social.technet.microsoft.com/Forums/windowsserver/en-US/a164b948-1778-42bd-8d77-9cef1ca70866/image-capture-boot-image-fails-with-0xc000000f?forum=winserversetup

Do NOT add a newer boot file into an older Windows Deployment Service

In my company, there is a Windows Deployment Service (WDS for short) hosted by Windows Server 2012 R2. Since I got the new release of Windows Server yesterday, named Windows Server 2012 R2 with Update, I added the boot.wim from the new CD into this server and began my nightmare.

Result: All boot images from installation CD work great. But all capture images are failed to start, no matter the capture image is pre-existed, new created or copied from other servers. They’re failed in 2 ways:

  • Error in \Windows\System32\boot\winload.exe with status code 0xc000000f after the loading bar completed; or,
  • Black screen after displaying the Windows logo.

To fix this, I’ve tried to remove the new added boot image but this trying is ineffective. Finally, I googled and find there is a person who added a Windows 8 Preview boot file into an old WDS server, which lead to the similar result. The way to fix is:

  1. Stop the WDS;
  2. Restore the Boot folder from a previous version; and,
  3. Restart the WDS.

If you don’t have backup, you may need to reinstall WDS.

I guess when you add a new boot image into a WDS, it will update the existed boot folder to the latest version, which may not be compatible with other boot files. Maybe it will be fixed after patching the server OS, but it’s better never to do such a thing again.


Update: There is another way to fix the broken capture image file directly. But you have to do that for every capture file. http://social.technet.microsoft.com/Forums/windowsserver/en-US/a164b948-1778-42bd-8d77-9cef1ca70866/image-capture-boot-image-fails-with-0xc000000f?forum=winserversetup

Enable Remote Management for Hyper-V Server

After a clean installation process, firewall of Hyper-V Server is set to deny any remote connection by default.

If you need to management other than using console, you may want to enable inbound rules for Remote Management and Remote Desktop by running these commands in the console.

To enable the Remote Management:

cscript C:\windows\system32\scregedit.wsf /im 1

To enable the Remote Desktop:

cscript C:\windows\system32\scregedit.wsf /ar 0

And, you need to enable the remote desktop from the sconfig (the blue console window) also.