Raspiblitz: Alternate Ports for bitcoind and lnd

Created on 18 Sep 2018  路  10Comments  路  Source: rootzoll/raspiblitz

If you run several RapsiBlitz in the same network behind a NAT firewall you want to forward ports, respectively use port triggering to lead the right data to particular nodes.

For that it was nice to have the option to change the ports bitcoind and lnd are listening to.

Also I would like to see an option to add additional ports opened in the firewall (ufw) before the reboot.

I could imagine both features in the main menu under "advanced" OR in the setup scripts before setup of the nodes, respectively before the firewall is enabled.

enhancement

Most helpful comment

We have found a solution to this, that hopefully works for everyone!

1) Login to your node and get to the console

2) We will open the new port that is wanted in the firewall with (For our case, we wanted port 9736)
sudo ufw allow 9736 comment 'lightning mainnet'
sudo ufw --force enable

3) Next we will add a listening port to our lnd.conf
sudo nano /home/admin/.lnd/lnd.conf

We will now add two new lines: (For XXX.XXX.XXX.XXX, please replace with your external IP)
listen=0.0.0.0:9736
externalip=XXX.XXX.XXX.XXX:9736

4) Save and exit File
CTRL + O
CTRL + X

Now we will add these to one more file, to cover all the bases:
sudo nano /home/bitcoin/.lnd/lnd.conf

We will now add two new lines: (For XXX.XXX.XXX.XXX, please replace with your external IP)
listen=0.0.0.0:9736
externalip=XXX.XXX.XXX.XXX:9736

5) Save and exit File
CTRL + O
CTRL + X

Now the fun part!

6) Stop lnd
sudo systemctl stop lnd

7) We will then disable lnd
sudo systemctl disable lnd

8) Now we will edit the lnd.service file
sudo nano /etc/systemd/system/lnd.service

9) Once the file is open look for
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}

When you have found that line, we will add the port we want to start using instead of the default 9735 to the end like so (In our case we used 9736)
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}:9736

10) We will save the file
CTRL + O

11) We will exit the file
CTRL + X

12) We will enable the lnd service again
sudo systemctl enable lnd

13) Now we will shutdown and restart the RaspiBlitz to have our changes go into effect.
sudo shutdown -r now

14) Verify changes have been made with:
lncli getinfo

15) You should now see your uris has changed! SUCCESS!
jmn6ivvy

All 10 comments

I just edited the lnd.conf in /mnt/hdd/lnd/ (the symlink from .lnd of bitcoin's home) and /home/admin/
and added

`# On all ipv4 interfaces on port 19735 and ipv6 localhost port 19736:
#listen=0.0.0.0:19735
#listen=[::1]:19736` 

But after reboot the infoscreens both on the device and via ssh show still 9735 as port. This is not only a display error also
lncli getinfo
shows 9735 as port.

Is the start with port 9735 "hardwired" in the call of lnd?
That should be changed.

The port displayed should be the one one from lncli getinfo / uris. Changing the port over the UI should be a future option. I never changed it, so experience here. Why lnd is not picking up the changed port you may get an answere at the LND Dev Slack.

The reason is that the frontend is running the command as a different user (admin instead of bitcoin), thus grabbing different configuration (lncli appears to directly access the config file and does not ask the server).

I'll make a PR later.

We have found a solution to this, that hopefully works for everyone!

1) Login to your node and get to the console

2) We will open the new port that is wanted in the firewall with (For our case, we wanted port 9736)
sudo ufw allow 9736 comment 'lightning mainnet'
sudo ufw --force enable

3) Next we will add a listening port to our lnd.conf
sudo nano /home/admin/.lnd/lnd.conf

We will now add two new lines: (For XXX.XXX.XXX.XXX, please replace with your external IP)
listen=0.0.0.0:9736
externalip=XXX.XXX.XXX.XXX:9736

4) Save and exit File
CTRL + O
CTRL + X

Now we will add these to one more file, to cover all the bases:
sudo nano /home/bitcoin/.lnd/lnd.conf

We will now add two new lines: (For XXX.XXX.XXX.XXX, please replace with your external IP)
listen=0.0.0.0:9736
externalip=XXX.XXX.XXX.XXX:9736

5) Save and exit File
CTRL + O
CTRL + X

Now the fun part!

6) Stop lnd
sudo systemctl stop lnd

7) We will then disable lnd
sudo systemctl disable lnd

8) Now we will edit the lnd.service file
sudo nano /etc/systemd/system/lnd.service

9) Once the file is open look for
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}

When you have found that line, we will add the port we want to start using instead of the default 9735 to the end like so (In our case we used 9736)
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}:9736

10) We will save the file
CTRL + O

11) We will exit the file
CTRL + X

12) We will enable the lnd service again
sudo systemctl enable lnd

13) Now we will shutdown and restart the RaspiBlitz to have our changes go into effect.
sudo shutdown -r now

14) Verify changes have been made with:
lncli getinfo

15) You should now see your uris has changed! SUCCESS!
jmn6ivvy

To setup this on a fresh raspiblitz - also I think in /mnt/hdd/lnd/lnd.conf the entry listen=0.0.0.0:9736is needed and a firewall port needs to be open on 9736:
sudo ufw allow 9736 comment 'lightning mainnet'
sudo ufw --force enable

I will edit the post above.

I am adding this to 1.1 release milestone ... as an idea for a script in /home/admin/config.scripts/lnd.setport.sh that simply takes the port number as parameter and executes the needed changes automatically :)

OK - the master branch contains now a experimental script called: lnd.setport.sh
Will be part of v1.1 if you have v1.0 running, you can get that script with running command: /home/admin/XXsyncScripts.sh before the command below.

So to change the LND port you now just go to the terminal (X Option in menu). And run this command: /home/admin/config.scripts/lnd.setport.sh [PORTNUMBER]

Closing issue - but test results are welcome. Everybody have fun.

Would this be the same process if I want to change the rpc 10009 and rest 8080 ports to connect with my wallet?

I will quickly explain maybe any of you can shed some light here... Since I'm on IPv6 my router assigns me a different port for all 4 standards; 8333,9735,10009 & 8080. Since I'm running behind tor the bitcoind and lnd ports (1st and 2nd) don't care much, but the last 2 are much needed whenever I want to connect with my Zap wallet for example. Would it be enough just to add 2 more lines to the lnd.conf with the new ports assigned by the router?

For changing the RPC & REST ports you need to edit the LND config manually .. see your options in this sample LND config: https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf

Was this page helpful?
0 / 5 - 0 ratings