Running A Full Node

Posted by Corentin Debains, David Harding

Running A Full Node

Please note: these instructions are for the 21 Bitcoin Computer. If you want to setup a full node for a general Mac OS X or Linux computer, please see the Bitcoin.org full node instructions.

What you'll learn

By the end of this tutorial, you'll have a Bitcoin Core full node running on your 21 Bitcoin Computer and your router configured so that you can provide blocks and transactions to lightweight Bitcoin clients and other peers.

Requirements

  • 21 Bitcoin Computer
  • The ability to download about 15 GB per month
  • The ability to upload about 150 GB per month

Installing

SSH into your Bitcoin computer either using a terminal in OS X or Linux, or by using PuTTY on Windows. (For details, please see the setup instructions.)

ssh twenty@IP_ADDRESS

Run the following commands. You should be able to copy and paste all of these in one block.

## Install bitcoind and the curl utility
sudo apt-get -y install bitcoind curl
## Change directory into its configuration directory
cd $HOME/.bitcoin/
## Get a configuration file
wget https://gist.githubusercontent.com/harding/d3b6f7c69568f220e1d6/raw/bitcoin.conf
## Ensure other users can't read the password in the configuration file
chmod 600 bitcoin.conf
## Add a password entry after a new line
echo >> bitcoin.conf
echo -n 'rpcpassword=' >> bitcoin.conf
## Create a random password
dd if=/dev/urandom bs=20 count=1 | shasum | sed 's/ .*//' >> bitcoin.conf
## Set bitcoind to start at boot
{ crontab -l ; echo ; } | sed '$a@reboot bitcoind -daemon' | crontab
## Start bitcoind now
bitcoind -daemon

This will setup everything you need and configure bitcoind to start automatically each time you reboot your 21 Bitcoin Computer. It will also start bitcoind immediately.

Important: bitcoind needs to be shut down safely. Failure to shut it down safely may trigger a database reindex that takes several days to complete on the 21 Bitcoin Computer. To ensure you always safely shutdown your computer before unplugging it, run the following command while logged into your 21 Bitcoin Computer at least five minutes before unplugging it:

sudo shutdown -h

This will disconnect you from the computer and stop all of the processes on the computer, including bitcoind.

Installing Bitcoin Core was the easy part. Now you have to configure your router.

Enabling connections

Enabling inbound connections requires two steps, plus an extra third step for firewall users:

  1. Giving your 21 Bitcoin Computer a static (unchanging) internal IP address by configuring the Dynamic Host Configuration Protocol (DHCP) on your router.

  2. Forwarding inbound connections from the Internet through your router to your computer where Bitcoin Core can process them.

Configuring DHCP

In order for your router to direct incoming port 8333 connections to your 21 Bitcoin Computer, it needs to know your computer's internal IP address. However, routers usually give network devices dynamic IP addresses that change frequently, so we need to ensure your router always gives your 21 Bitcoin Computer the same internal IP address.

Start by logging into your router's administration interface. Most routers can be configured using one of the following URLs, so keep opening URLs until you find one that works. If none work, consult your router's manual.

  • http://192.168.0.1 (some Linksys/Cisco models)
  • http://192.168.1.1 (some D-Link/Netgear models)
  • http://192.168.2.1 (some Belkin/SMC models)
  • http://192.168.123.254 (some US Robotics models)
  • http://10.0.1.1 (some Apple models)

Upon connecting you will probably be prompted for a username and password. If you configured a password, enter it now. If not, the Router Passwords site provides a database of known default username and password pairs.

After logging in, you want to search your router's menus for options related to DHCP, the Dynamic Host Configuration Protocol. These options may also be called Address Reservation. For example, the router page shown below calls the option we need "DHCP Reservation":

DHCP reservation button

In the reservation configuration, some routers will display a list of computers and devices currently connected to your network, and then let you select a device to make its current IP address permanent:

Easy DHCP reservation

If that's the case, find the 21 Bitcoin Computer in the list, select it, and add it to the list of reserved addresses. Make a note of its current IP address---we'll use the address in the next section.

Other routers require a more manual configuration. For these routers, you will need to look up the fixed address (MAC address) for your 21 Bitcoin Computer's network card and add it to the list. If you have to do this, SSH into your 21 Bitcoin Computer using either a terminal or PuTTY, and type the following command:

ifconfig

Among the results, you should one set that starts like this:

wlan0     Link encap:Ethernet  HWaddr 04:8d:38:c8:2d:94
          inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0

Look at the HWaddr field; this will have the MAC address for your 21 Bitcoin Computer's USB WiFi device. Also look at the inet addr: field; this is your IP address.

Once you have the MAC address, you can fill it into to your router's manual DHCP assignment table, as illustrated below. Also enter your IP address. After entering this information, click the Add or Save button.

Manual DHCP reservation

After completely saving everything on your router. Reboot your 21 Bitcoin Computer from the SSH session by typing:

sudo reboot

Wait 30 seconds and then log back in using SSH. If you have any problems, refer to the setup instructions.

Port forwarding

For this step, you need to know the local IP address of the computer running Bitcoin Core. You should have this information from configuring the DHCP assignment table in the subsection above.

Log in to your router using the same steps described near the top of the DHCP subsection. Look for an option called Port Forwarding, Port Assignment, or anything with "Port" in its name. On the some routers, this option is buried in an Applications & Gaming menu.

The port forwarding settings should allow you to map an external port on your router to the "internal port" of a device on your network as shown in the screenshot below.

Port forwarding

Both the external port and the internal port should be 8333 for Bitcoin. Make sure the IP address you enter is the same one you configured in the previous subsection.

After filling in the details for the mapping, save the entry. You should not need to restart anything.

Testing your connection

We provide a simple online tool to let you test whether your node accepts inbound connections. Make sure that you've started Bitcoin Core and that it's been running for at least five minutes. Then use your laptop to visit our Bitcoin Nodes web page.

The tool will fill in your router's current IP address and the port 8333 we setup earlier, so all you need to do is click Check Node. If you get the green box, you're all done. If you got the red box, it's possible that your laptop has a different external IP address than your 21 Bitcoin Computer. Using your SSH session, run this command on your 21 Bitcoin Computer:

curl ifconfig.co

This will print your IP address; if it's different than the one you tried earlier, enter it into the Bitnodes tool. If it's the same, please re-read the instructions above to see if you missed a step or join our friendly chatroom to get help.