-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save information on how to host for free (without port forwarding) #325
Comments
using wireguard to achieve something interesting (from https://www.reddit.com/r/selfhosted/comments/11t7gxd/self_hosting_game_servers_without_port_forwarding/ if it gets deleted): I can help you, I created a linode nanode that does the same thing. Just late rn so I will make a writeup on the iptables needed to get it working. I created some scripts to automate it a tad but not to the extent I would like. Essentially you create vm in the cloud running wireguard then connect your containers or servers to the vm. From there it's all packet forwarding using iptables essentially turning the cloud vm into a nat router for your servers. (This will not require port-forwarding so you can technically run your servers anywhere there is internet) Ping can be a problem however with wireguard I only notices a 1-4ms increase in ping however my experience is with fiber internet. For the server that will be essentially be a proxy: Wireguard wg0 config I use for the server. [Interface]
PrivateKey = {Generated Server Private Key}
Address = 10.2.2.1/32
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
SaveConfig = true
ListenPort = 51820
[Peer]
PublicKey = {Client Public Key}
AllowedIPs = 10.2.2.10/32 to quickly add peers to your config you can use the command wg set wg0 peer {Client Public Key} allowed-ips 10.2.2.10/32 just remember to change the peer ip to what you want in your configuration. make sure to change eth0 to your interface name.
To generate a key simply use the command wg genkey > privatekey
Make sure that each time the server reboots the above iptable commands are saved or reapplied. If you use the 6th command make sure to open ssh port so you dont lock yourself out.
When doing this make sure to again change the eth0 interface to the interface which your vps uses to face publicly. What this does is it acts like a router using NAT to forward packets to the internet from the server. Replace the [Host] with the ip you assigned to your server you want to forward. As promised I will also add my script as an example on how I forward all my websites and servers to my Wireguard server #!/bin/sh
iptables -A FORWARD -i wg0 -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o wg0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#iptables -P FORWARD DROP
#Routing the servers
echo "Routing Servers Now"
echo "Routing Games"
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 25565 -j DNAT --to-destination 10.0.0.40
iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 25565 -d 10.0.0.2 -j SNAT --to-source 10.0.0.40
iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 25565 -m conntrack --ctstate NEW -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 27051 -j DNAT --to-destination 10.0.0.11
iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 27051 -d 10.0.0.11 -j SNAT --to-source 10.0.0.1
iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 27051 -m conntrack --ctstate NEW -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 27053:27054 -j DNAT --to-destination 10.0.0.11
iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 27053:27054 -d 10.0.0.11 -j SNAT --to-source 10.0.0.1
iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 27053:27054 -m conntrack --ctstate NEW -j ACCEPT
#Websites
echo "Routing Websites"
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.13
iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.0.0.13
iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 443 -m conntrack --ctstate NEW -j ACCEPT For my servers I used the subnet of 10.0.0.0/24 with multiple servers yours may vary. When doing this make sure to port forward every port you want to use for your servers and the wireguard port. This is my quick and dirty setup with a terrible explanation however if you have any questions feel free to ask. This will require you to install wireguard for either the clients or I did it with an opnsense vm that was a router behind a router and just routed all traffic to the vps. |
What
save information on how to enable access to a service from many devices (ideally for free)
cloudflare tunnels
nordvpn meshnet (like local area network)
tunnel info
how do cloud servers handle power outage
wireguard allows connections between two devices
Why
i need a way to keep up with all the information i gather and it's the best if i write down everything i find (and need)
The text was updated successfully, but these errors were encountered: