Configure WireGuard Option: Tunnel
To configure WireGuard, you need to edit the configuration file for the interface. The following is an example configuration:
[Interface]
Address = 10.192.1.254/24
SaveConfig = true
ListenPort = 51820
PrivateKey = xxxXXXxxx
PostUp = iptables -A FORWARD -i % -j ACCEPT;Explanation of Configuration Options
Address: This option sets the IP address and subnet for the interface. In this example, the IP address is 10.192.1.254 and the subnet is /24, which means it has a 256-bit subnet mask of 255.255.255.0.
SaveConfig: This option saves the configuration file after it has been applied. This is useful for keeping track of changes made to the configuration.
ListenPort: This option sets the port number that WireGuard listens on for incoming connections. In this example, the port number is 51820.
PrivateKey: This option sets the private key for the interface. This key is used to authenticate the interface and encrypt traffic.
PostUp: This option specifies a command to be run after the interface is brought up. In this example, the command is used to allow incoming traffic on the interface.
Adjustments for One-Way Connection
For a one-way connection, you need to make some adjustments to the configuration. Specifically, you need to remove the PostUp option and add a PreUp option. The PreUp option specifies a command to be run before the interface is brought up.
[Interface]
Address = 10.192.1.254/24
SaveConfig = true
ListenPort = 51820
PrivateKey = xxxXXXxxx
PreUp = iptables -A INPUT -p udp --dport 51820 -j ACCEPT;In this example, the PreUp option is used to allow incoming traffic on the interface before it is brought up. This is necessary for a one-way connection because the interface will not be able to receive incoming traffic if it is not already allowed.
- Configure WireGuard by editing the interface configuration file.
- Use the Address option to set the IP address and subnet for the interface.
- Use the SaveConfig option to save the configuration file after it has been applied.
- Use the ListenPort option to set the port number that WireGuard listens on for incoming connections.
- Use the PrivateKey option to set the private key for the interface.
- For a one-way connection, use the PreUp option to allow incoming traffic on the interface before it is brought up.