Nyr / wireguard-install

WireGuard road warrior installer for Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option "Change port"

DanielKOcean opened this issue · comments

Sometimes user needs to change port without reinstalling WireGuard. It would be a good idea to add "Change port" option to Add/Delete user menu.

What Port do you want to change? The Wireguard Port on the Server? This is a really bad idea, because you need to touch every config on every client you already use.

If you really need to do that, you have to replace this port manually in your server config, script, firewall rules and all client configs on all clients. This can't be done via this script.

What Port do you want to change? The Wireguard Port on the Server? This is a really bad idea, because you need to touch every config on every client you already use.

If you really need to do that, you have to replace this port manually in your server config, script, firewall rules and all client configs on all clients. This can't be done via this script.

I understand what you are talking about. But I use WireGuard server as a personal one, so have 2 devices connected. Changing port number on them is not a problem. The problem is that I live in a country, where government blocks server port after a day or two when see that this port is used for VPN traffic. The solution is to run command on server and change two configs on devices, than to reinstall wire guard with the new port, recreate users and transfer configs to devices.

commented

While this will not be implemented into the script, I understand your use case. In the server, you can redirect ports like this, assuming you are using Debian and no firewall:
iptables -t nat -A PREROUTING -p udp -d $IP --dport $NEW_PORT -j REDIRECT --to-port $OLD_PORT

  • $IP is the IP of your server
  • $OLD_PORT is the port where WireGuard is listening originally
  • $NEW_PORT is the new port where you want WireGuard to be available

You can run this multiple times to set up multiple ports and even use a big range and change on demand from the client. That said, there are better tools than WireGuard to evade filtering, if the need arises.