📅  最后修改于: 2023-12-03 14:59:13.609000             🧑  作者: Mango
In this guide, we will explore WireGuard setup on Amazon Linux using Bash shell scripts. WireGuard is a modern VPN (Virtual Private Network) technology that aims to be faster, simpler, and more secure than traditional VPN protocols.
With WireGuard, you can create secure connections between multiple devices or networks over the internet. It provides a lightweight and efficient solution for establishing encrypted communication channels.
To follow this guide, you need the following:
Launch your Amazon Linux instance and connect to it via SSH.
Update the system packages:
sudo yum update -y
sudo yum install -y kernel-headers kernel-devel
wget https://git.zx2c4.com/WireGuard/snapshot/WireGuard-X.XX.tar.xz
Replace X.XX with the desired version number of WireGuard.
tar -xf WireGuard-X.XX.tar.xz
cd WireGuard-X.XX
make
sudo make install
sudo modprobe wireguard
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey
sudo vi /etc/wireguard/wg0.conf
wg0.conf
file:[Interface]
PrivateKey = <server_private_key>
Address = <server_IP>/24
ListenPort = 51820
[Peer]
PublicKey = <client_public_key>
AllowedIPs = <client_IP>/32
Replace the
<server_private_key>
,<server_IP>
,<client_public_key>
, and<client_IP>
with appropriate values.
sudo wg-quick up wg0
To use WireGuard, you need to configure it on both the server and client devices. The server will listen for incoming connections, while the client will initiate the connection.
sudo firewall-cmd --add-port=51820/udp --permanent
sudo firewall-cmd --reload
# Install WireGuard
sudo apt-get install -y wireguard
# Create client configuration file
sudo vi /etc/wireguard/wg0.conf
# Add the following content to the `wg0.conf` file
[Interface]
PrivateKey = <client_private_key>
Address = <client_IP>/24
[Peer]
PublicKey = <server_public_key>
Endpoint = <server_IP>:51820
AllowedIPs = 0.0.0.0/0, ::/0
Replace the
<client_private_key>
,<client_IP>
,<server_public_key>
, and<server_IP>
with appropriate values.
sudo wg-quick up wg0
Congratulations! You have successfully set up WireGuard on Amazon Linux using Bash shell scripts. With WireGuard, you can establish secure VPN connections between devices or networks. Make sure to customize the configuration according to your specific requirements.
Remember to keep your WireGuard configurations and keys secure, as they are crucial for maintaining the integrity and confidentiality of your VPN communications.
Happy wireguarding!