sandstorm-io/sandcats

Sandcats IP detection doesn't work when binding to a secondary network interface

strugee opened this issue · 2 comments

I have several IP addresses allocated to a single network interface:

% ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 20:47:47:82:d5:8c brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 20:47:47:82:d5:8e brd ff:ff:ff:ff:ff:ff
    inet 216.160.72.225/24 brd 216.160.72.0 scope global eth1
       valid_lft forever preferred_lft forever
    inet 216.160.72.226/24 brd 216.160.72.0 scope global secondary eth1:0
       valid_lft forever preferred_lft forever
    inet 216.160.72.227/24 brd 216.160.72.0 scope global secondary eth1:1
       valid_lft forever preferred_lft forever
    inet 216.160.72.228/24 brd 216.160.72.0 scope global secondary eth1:2
       valid_lft forever preferred_lft forever
    inet 216.160.72.229/24 brd 216.160.72.0 scope global secondary eth1:3
       valid_lft forever preferred_lft forever

Here's my Sandstorm config:

SERVER_USER=sandstorm
PORT=80,6080
HTTPS_PORT=443
MONGO_PORT=6081
BIND_IP=216.160.72.228
BASE_URL=https://strugee.sandcats.io
WILDCARD_HOST=*.strugee.sandcats.io
UPDATE_CHANNEL=dev
ALLOW_DEV_ACCOUNTS=false
SANDCATS_BASE_DOMAIN=sandcats.io

Regrettably, despite the fact that I've specified another IP to bind to, Sandcats is apparently still getting UDP packets from my primary IP (216.160.72.225). So the DNS is wrong and I can't access my Sandstorm server :(

I'm opening this in case there's something smart to do in this particular case (not sure that there is) - but it may be that this just ends up being a dupe of #121.

Any interest in writing a patch? FWIW the code that you'd need to adjust is in shell/server/sandcats.js. In both pingUdp() and updateSandcatsIp(), you would need to arrange for the requests to bind to process.env.BIND_IP.

@kentonv already looking into it 😊