Configuring Site-to-Site Connection with OpenVPN and DD-WRT Routers

In today’s interconnected world, the ability to securely connect multiple networks is of paramount importance. OpenVPN, a versatile and secure open-source VPN solution, offers a powerful way to bridge two routers together using DD-WRT firmware. By creating a site-to-site connection, it becomes possible to extend a local network over the internet, allowing resources to be accessed from different locations securely.
Configuring OpenVPN in a site-to-site mode involves several steps, but with the right instructions, it can be done easily. Before getting started, it is important to have a DD-WRT compatible router and a good understanding of networking concepts such as IP addressing, subnetting, and routing.
The first step in the process is to install DD-WRT firmware on both routers. Once installed, the routers need to be configured to act as OpenVPN servers. This involves generating the necessary certificates and keys, setting up the routing tables, and enabling the OpenVPN server. The client-side routers also need to be configured to connect to the server routers using the generated certificates and keys.
After the server and client routers are configured, the next step is to configure the firewall rules on both sides to allow OpenVPN traffic. This includes allowing the OpenVPN port (usually 1194) through the firewall, as well as any additional ports that may be required for specific applications or services. It is also important to enable multicast forwarding if it is required in the network.
With the configuration complete, it is now possible to test the site-to-site connection. It is important to ensure that the routers can ping each other, as well as any other devices within the network. Additionally, testing the connection from a computer located on one side of the network to a device located on the other side can help validate the connectivity.
Configure the Client Router
Edit the OpenVPN configuration file
Before configuring the client router, we need to edit the OpenVPN configuration file on the DD-WRT web interface. This file, typically named “openvpn.conf”, contains the necessary settings for the OpenVPN connection. To access this file, navigate to the Services tab and click on the VPN sub-tab.
Add necessary OpenVPN settings
The following settings need to be added to the OpenVPN configuration file on the client router:
- remote: Specify the domain name or IP address of the server router that we are connecting to.
- proto: Specify the protocol used for the OpenVPN connection. This can be either “tcp” or “udp”.
- nobind: This option prevents OpenVPN from binding to a specific local port.
- client: This option tells OpenVPN that this configuration file is for a client.
- daemon: This option causes OpenVPN to run in the background as a daemon.
- serverkey: This option specifies the key file used to authenticate the client to the server.
Configure the client router as an OpenVPN client
To configure the client router as an OpenVPN client, follow these steps:
- Install the OpenVPN package on the client router. This can be done through the DD-WRT firmware interface.
- Copy the generated key files (server.crt, server.key, ca.crt) from the server router to the client router.
- Create an OpenVPN start-up script on the client router by navigating to the Administration tab and clicking on the Commands sub-tab.
- Enter the necessary OpenVPN commands to configure the client router. These commands include specifying the keys and certificates, as well as the IP address and port of the server router.
- Save the script and restart the client router.
Configure the client router to handle forwarded traffic
After the OpenVPN connection is established, the client router needs to be configured to handle the incoming and outgoing traffic from the server router. This can be done by enabling the necessary firewall rules on the client router.
- Enable forwarding: By default, incoming connections are blocked by the client router. To allow the forwarded traffic, the client router needs to have forwarding enabled.
- Allow traffic through the client router: The client router needs to have firewall rules in place to allow certain types of traffic to pass through. This can include allowing specific ports or protocols.
Configure the client router to handle multicast traffic
If you want to handle multicast traffic between the server and client routers, additional configuration is required. This can be done by enabling the necessary multicast settings on the client router.
- Enable multicast: By default, multicast traffic is blocked by the client router. To allow multicast traffic to pass through, the client router needs to have multicast enabled.
- Configure IGMP: IGMP (Internet Group Management Protocol) needs to be properly configured on the client router to handle multicast traffic.
With these configurations in place, the client router should be able to establish an OpenVPN connection with the server router and handle the forwarded and multicast traffic between the two routers.
Generate Keys for Authentication
The first step in configuring OpenVPN for site-to-site communication is to generate the necessary keys for authentication. These keys will be used to verify the identity of the connecting devices and ensure a secure connection.
To generate the keys, you will need to use the OpenVPN “easy-rsa” script, which is included with the OpenVPN package. This script provides a simple way to generate the necessary certificates and keys for authentication.
Before you can generate the keys, you will need to navigate to the directory where the “easy-rsa” script is located. This is typically located in the “keys” folder of your OpenVPN installation. Once you are in the correct directory, run the following command to generate the keys:
- First, run the command “source ./vars” to initialize the necessary environment variables.
- Next, run the command “./build-key server” to generate the server key pair.
- Then, run the command “./build-key client” to generate the client key pair.
- Finally, run the command “./build-dh” to generate the Diffie-Hellman parameters.
After running these commands, the necessary keys will be generated and located in the “keys” folder. You will need to copy the generated keys to the appropriate locations on both routers for the authentication process to work correctly.
Once the keys are generated, you can proceed with the configuration of the OpenVPN server and client. This will involve creating the OpenVPN configuration files and specifying the necessary parameters for the site-to-site connection. The configuration files should include the generated keys and certificates, as well as the IP address and port of the remote VPN server.
With the keys and configuration files in place, you can now start the OpenVPN service on both routers. This will establish the site-to-site connection between the two networks and allow for secure communication.
Configure the Server Router
The first step in setting up a site-to-site VPN configuration is to configure the server router. In this tutorial, we will be using DD-WRT firmware on both routers. DD-WRT is a Linux-based firmware that unlocks the full potential of routers and provides advanced features such as OpenVPN support.
To configure the server router, you will need to access its web interface. Open your favorite web browser and enter the IP address of the server router in the address bar. This address is usually 192.168.1.1, but it may be different depending on your network setup. Once you have accessed the web interface, navigate to the “Services” tab.
Under the “Services” tab, you will find various settings related to network services. Scroll down until you see the “OpenVPN” section. Enable the OpenVPN server by checking the box next to “Start OpenVPN server” and set the “OpenVPN Daemon” option to “Enable”. These settings will allow the server router to act as an OpenVPN server and accept incoming VPN connections.
In the “OpenVPN” section, you will also find options to configure the OpenVPN protocol, server mode, and network settings. For most setups, the default values should work fine. However, you can customize these settings if necessary.
Next, scroll down to the “Additional Config” section. In the text box labeled “Custom Configuration”, enter the following commands:
echo "brctl addbr br0
brctl addif br0 eth1_dev
brctl addif br0 tun0"
echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "0" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
These commands will create a network bridge (br0) and add the Ethernet interface (eth1_dev) and the OpenVPN interface (tun0) to the bridge. They also disable some ICMP blocking to allow for proper communication between the bridge and the connected networks.
After entering the commands, click the “Save” button to apply the changes. The server router is now configured and ready to establish a site-to-site VPN connection with the client router.
Install DD-WRT onto Your Routers
Installing DD-WRT firmware onto your routers is an important step that will allow you to configure OpenVPN for a site-to-site connection. Here are the instructions to install DD-WRT:
- Download the DD-WRT firmware for your specific router model from the official website.
- Connect your computer to the router via Ethernet cable.
- Login to the router’s web interface using the default IP address (usually 192.168.1.1) and default login credentials.
- Navigate to the “Firmware Upgrade” section in the router’s web interface.
- Click on the “Choose File” or “Browse” button and select the downloaded DD-WRT firmware file.
- Click on the “Upgrade” or “Install” button to start the firmware installation process.
- Wait for the router to reboot and complete the firmware installation.
- Once the router has successfully rebooted, configure basic settings such as wireless network name (SSID) and password.
- Repeat the above steps for all routers that you want to use for the site-to-site connection.
After installing DD-WRT firmware on all routers, you can proceed with the OpenVPN configuration for bridging the two routers.
Blocking DHCP requests through the VPN
One important consideration when setting up an OpenVPN Site-to-Site Configuration with DD-WRT routers is blocking DHCP requests through the VPN. By default, DD-WRT handles DHCP requests from clients on the LAN side and forwards them to the VPN. However, in some cases, it may be necessary to block these requests from being sent over the VPN.
To block DHCP requests through the VPN, you will need to modify the router’s configuration files. This can be done by accessing the router’s administration interface and navigating to the Services tab. From there, you can edit the configuration file using the JFFS2 file system.
Once in the JFFS2 file system, you will need to find the configuration files related to DHCP and modify them accordingly. The exact instructions will vary depending on your router and its firmware. However, you will likely need to edit the DHCP options and specify that DHCP requests should not be forwarded through the VPN.
After making the necessary changes, you will need to apply the configuration and restart the router. This will ensure that the changes take effect and that DHCP requests are no longer being sent over the VPN.
By blocking DHCP requests through the VPN, you can ensure that clients on the LAN side of the router receive their IP addresses and configuration information from the local DHCP server, rather than from the remote VPN server. This can help prevent conflicts and improve network performance.
How do I join two subnets with two DD-WRT routers?
If you have two DD-WRT routers and want to join two subnets, you can do so by configuring a site-to-site VPN using OpenVPN. This tutorial will guide you through the process of creating a bridge between the two routers, allowing devices on each subnet to communicate with each other.
Step 1: Install and configure DD-WRT
To start, make sure both routers are running the DD-WRT firmware. If not, you’ll need to install it following the instructions provided by the DD-WRT website. Once installed, access the router’s admin interface and configure the basic settings, such as the router’s name and IP address.
Step 2: Configure the OpenVPN service
Next, enable the OpenVPN service on both routers. This can be done by navigating to the Services tab in the DD-WRT admin interface and checking the “Enable” box next to OpenVPN. Save the changes and wait for the services to restart.
Step 3: Generate the keys and certificates
On one of the routers, go to the Services tab, scroll down to the OpenVPN section, and click on the “VPN Server” tab. Generate the keys and certificates by clicking on the “Generate” button next to “Static key” and “Certificate Authority”. Save the generated keys and certificates to a folder on your computer.
Step 4: Create the OpenVPN configuration files
Using a text editor, create two OpenVPN configuration files – one for each router. The configuration file should include the following commands:
- dev tap
- management localhost 5001
- management-hold
- proto udp
- port 1194
- ifconfig 192.168.2.1 255.255.255.0
- route 192.168.1.0 255.255.255.0
- keepalive 10 120
- comp-lzo
- persist-key
- persist-tun
- status-version 2
- status status
- verb 3
Step 5: Edit the configuration files
Open each configuration file and edit the following lines:
- Replace “myvpn” with a unique name for your VPN.
- Replace “vpnipup” with the IP address of the router running the OpenVPN server.
- Replace “tmpclient.crt” with the generated client certificate file name.
- Insert the gateway addresses of the routers in the “push” lines.
Step 6: Create a bridged connection
On both routers, enable the bridged mode by going to the Setup tab and selecting “Bridged” in the “Router IP” section. Save the changes and wait for the routers to reboot.
Step 7: Start the OpenVPN service
On each router, navigate to the Services tab and click on the “Start Now” button next to the OpenVPN service. The routers will now become peers and the VPN will be established.
With these steps, you should be able to configure a site-to-site VPN between two DD-WRT routers, allowing devices on each subnet to communicate with each other. Remember to configure your devices’ network settings to use the respective router’s IP addresses as the gateway.
Answers 3
1. Configuring the OpenVPN Server on the Router

To establish a site-to-site connection using OpenVPN with DD-WRT routers, you will need to configure the OpenVPN server on the primary router. Start by accessing the router’s admin interface and navigating to the “Services” tab. Then, find the “OpenVPN” section and click on “Enable” to activate the OpenVPN daemon.
2. Generating and Sharing Keys
To enable secure communication between the routers, you will need to generate keys on both the primary and secondary routers. On the primary router, go to the “Administration” tab and click on “Commands.” In the “Commands” box, enter the following commands to generate the necessary keys:
tmpebt_ipo:/tmp # openvpn –genkey –secret /tmp/ta.key
The above command will generate a key “ta.key” in the “/tmp” folder.
3. Configuring the OpenVPN Server
Next, navigate to the “VPN” tab on the primary router’s admin interface. Under the “OpenVPN” section, you will find the “OpenVPN Server” configuration. Here, select the appropriate values for the “Protocol” (usually “UDP” or “TCP”) and “Port” fields. You may also configure additional options like “Compression” and “Verbosity” according to your needs.
4. Enabling Static Routing

To enable routing between the two routers, you will need to configure static routes. On the primary router, go to the “Administration” tab and click on “Commands.” Enter the following command to enable static routing:
route add -net [secondary_router_subnet] netmask [subnet_mask] gw [gateway] eth0
Replace [secondary_router_subnet], [subnet_mask], and [gateway] with the appropriate values for your network setup.
5. Joining the Secondary Router to the VPN

On the secondary router, navigate to the “Services” tab in the admin interface. Under the “OpenVPN Client” section, click on “Enable.” Then, click on “Edit” to configure the OpenVPN client settings. In the “OpenVPN Client” configuration, copy and paste the contents of the “openvpn.conf” file generated on the primary router into the “Configuration” box.
6. Saving and Starting the OpenVPN Service
After configuring the OpenVPN client on the secondary router, click on “Save” to save the settings. Then, click on “Apply Settings” to start the OpenVPN service. You can verify the status of the service by checking the “Status” tab.
7. Editing Firewall Rules
To allow OpenVPN traffic through the firewall, you will need to edit the firewall rules on both the primary and secondary routers. On the primary router, go to the “Administration” tab and click on “Commands.” Enter the following command to allow OpenVPN traffic:
iptables -I FORWARD -i [VPNInterface] -o [LANInterface] -j ACCEPT
Replace [VPNInterface] with the interface name used for the VPN (e.g., “tun0”) and [LANInterface] with the interface name used for the LAN (e.g., “br0”).
8. Configuring Dynamic Routing
If you have multiple clients connected to the secondary router and need to configure dynamic routing, you can do so by enabling the “Client-to-Client” option under the “OpenVPN” section on the primary router. This will allow the secondary router’s clients to communicate with each other over the VPN connection.
Вопрос-ответ:
What is OpenVPN?
OpenVPN is an open-source software application that implements virtual private network (VPN) techniques to create secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol based on SSL/TLS for key exchange and encryption.
What is Site-to-Site Configuration?
Site-to-site configuration, also known as gateway-to-gateway configuration, is a networking configuration that allows multiple locations or networks to connect and communicate with each other securely over the internet. It typically involves connecting two or more local area networks (LANs) together using VPN technology.
How can I bridge two routers with DD-WRT?
To bridge two routers with DD-WRT, you will need to configure both routers with OpenVPN and enable bridging mode. This can be done by following the step-by-step instructions provided in the article. Once the routers are bridged, they will be able to communicate with each other as if they were on the same local network.
What are the benefits of using OpenVPN for site-to-site configuration?
There are several benefits of using OpenVPN for site-to-site configuration. Firstly, OpenVPN provides a high level of security through encryption and authentication, ensuring that the data transmitted between the two networks remains confidential. Secondly, it is an open-source software, which means it is constantly being updated and improved by a large community of developers. Lastly, OpenVPN is compatible with multiple operating systems, making it a versatile choice for connecting different types of networks.
Видео:
Set up an OpenVPN Server on your DD-WRT Router
Set up an OpenVPN Server on your DD-WRT Router by DevbaseMedia 2 years ago 24 minutes 29,132 views