-
Notifications
You must be signed in to change notification settings - Fork 5
4. Static IP & Forwarding ports
In this tutorial you set a static IP for your server so its IP doesn't change when your router restarts or your server disconnects from it. You will also open the required ports in your router to be able to connect from outside your network.
-
These instructions are written for Debian-based Linux distributions (Debian, Ubuntu, Raspbian...). You may need to change some of the commands for them to work in other Linux distros, and Windows is unsupported and will most likely not work.
-
Even though it isn't required, you should already have a Hermes server and Nginx proxy running before following these instructions! Follow guides #1, #2 and #3 to get this.
(This has only been tested on a Raspberry Pi, it might not work on other devices / operating systems).
First, disable Predictable Network Names by entering sudo raspi-config --> Network options --> Network interface names --> No.
Then exit by clicking Finish. If it asks you to restart your Pi, click yes.
When your Raspberry Pi restarts, reconnect and enter this command:
sudo nano /etc/dhcpcd.conf
It will open a text file. Go to the bottom of the file and paste this in:
interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.1
interface wlan0
static ip_address=192.168.1.10/24
static routers=192.168.1.1
These commands set the IP of your device to 192.168.1.10, so it won't change if you restart your router.
Click CTRL + X to exit, and Y to save. Then enter sudo reboot to restart the Pi again.
Right now, you can only connect to your server if you are connected to the same network as your device. You have to open those ports on your router to be able to connect from anywhere.
This procedure is different for every router, but it usually involves connecting to the router configuration page (normally on 192.168.1.1), going to the "Ports" section and creating new rules.
When you get to the port configuration page, create the following rules:
- Internal / external port 80 (Required for HTTP and HTTPS servers)
- Internal / external port 443 (Optional, required for HTTPS server)
- Internal / external port 3000 (Optional, required for webhook configuration on page 7)
- Internal / external port 22 (Optional, used for SSH connections from outside your network)
(For the IP field, enter the IP of your device (It's 192.168.1.10 if you set a static IP using the instructions above)
When you are done, save the rules. You should now be able to access your server from anywhere.
You should have a static IP and the ports open in your router!
- If you don't, go back and make sure you did everything correctly.
- If you do, you can continue to the next step.