Category Archives: Software

OVH / SoYouStart Adding Failover IP

I am currently running a Tor exit node on a private server. This has caused the IP to be blacklisted from many services, mainly Freenode’s IRC server. In order to circumvent this I used SoYouStart’s built in “failover ip” service to create a second IP address I can bind applications to that were blacklisted, like an IRC client. My server comes with 16 free IP addresses I can virtually assign to the same NIC. There was a $3 set up fee though.

After getting the IP address assigned by the provider, I modified my /etc/network/interfaces file, adding this entry

auto eth0:1
iface eth0:1 inet static
        address [IP.ADDRESS.SYS.GAVE.ME]
        netmask 255.255.255.255

Once this was added a simple

/etc/init.d/networking restart

added the interface!

eth0      Link encap:Ethernet  HWaddr *:*:*:*:*:*
          inet addr:[ORIGINAL.SERVER.IP.ADDRESS]  Bcast:[ORIGINAL.SERVER.IP.ADDRESS]  Mask:255.255.255.0
          inet6 addr: [ORIGINAL:SERVER:IPv6:ADDRESS]::/64 Scope:Global
          inet6 addr: [ORIGINAL:SERVER:IPv6:ADDRESS]::/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:96259868 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89513036 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:69831382581 (65.0 GiB)  TX bytes:56016587742 (52.1 GiB)
          Interrupt:20 Memory:fe500000-fe520000

eth0:1    Link encap:Ethernet  HWaddr *:*:*:*:*:*
          inet addr:[IP.ADDRESS.SYS.GAVE.ME]  Bcast:[IP.ADDRESS.SYS.GAVE.ME]  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:20 Memory:fe500000-fe520000

Installing Bitcoin Core on Headless Debian 8

This past week I took a few hours to get a Bitcoin full node running on my Debian server. As a believer in the Bitcoin project I’m more than happy to host a full node on my media server.

Compilation

From your home directory clone the bitcoin project. I used the 0.11 branch.

git clone https://github.com/bitcoin/bitcoin -b 0.11

Following the directions from the github readme I configured and compiled.

I installed the necessary tools and libraries to compile the code.

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev

Then I got the build environment set up.

./autogen.sh

Since I didn’t need wallet functionality, I didn’t need to install Berkeley DB. I also enabled hardening because, well because why not right? Extra security!

./configure --disable-wallet --enable-hardening

After the configuration was complete I compiled. I noticed make was only utilizing one core and was taking a long time to run. I reran with make configured to utilize 9 (n + 1) cores.

make -j9

Since I’m on Debian I wanted to package the code up so I could install it via dpkg. CheckInstall puts the code into a .deb file that dpkg can then install. This will allow for future uninstall or upgrades to go smoothly, and is better than blindly placing files into the system.

sudo checkinstall

Next I needed to create a configuration file for bitcoind to use. I created a new bitcoin.conf file in ~/.bitcoin/ and placed the following text in it.

# server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands
server=1

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
rpcuser=superSecretUsername
rpcpassword=superSecretPassword

Autorun

I created a .service file for Debian so the application would autostart. I created a “bitcoinuser” user and “bitcoin” group for the process to run under.

[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target

[Service]
User=bitcoinuser
Group=bitcoin

Type=forking
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoinuser/.bitcoin/bitcoin.conf -datadir=/home/bitcoinuser/.bitcoin/

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=20s
StartLimitInterval=1s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

I placed it in /lib/systemd/system/bitcoind.service

After creating, I updated the system to pick up the changes.

sudo systemctl daemon-reload

Then I could issue nice commands to handle everything for me like

sudo service bitcoind start

Remote Status

I wanted to be able to monitor the status of bitcoind remotely via the web, which requires bitcoind to listen to JSON-RPC commands. Craig Watson has a nice PHP project to do just this. I cloned his github repo and installed it into Apache. It needed a small amount of configuration, mainly setting the RPC username and password (that I assigned in the bitcoin.conf file previously), as well as configuring what information I wanted displayed on the main page. After installing the website and configuring Apache with the new route I got a nice screen.

Capture

It’s Working!

It took around 24 hours for it to download the entire blockchain (around 55GB at time of writing), quite surprising with the fast connection the server has.