Running Multiple PreSearch nodes on one host using multiple IP addresses

nano /etc/sysctl.conf
change/verify net.ipv4.ip_forward to = 1

For each IP address (change the number after the : to the next higher number each time; change the docker network to the next higher subnet [172.23.0.0/16, 172.24.0.0/16, etc], increment the docker bridge name for each IP [bridge-ps2, bridge-ps3, etc.]):

cd /etc/sysconfig/network-scripts/

cp ifcfg-eno1 ifcfg-eno1:0

nano ifcfg-e*1:0
change DEVICE=eno1 to DEVICE=eno1:0
change IPADDR= to your other IP

/etc/init.d/network restart

docker network create --subnet 172.22.0.0/16 --gateway=172.22.0.1 --attachable --opt 'com.docker.network.bridge.name=bridge-ps1' bridge-ps1
optional to verify: docker network inspect bridge-ps1

Set the to-source to the other IP address from above

iptables -t nat -I POSTROUTING -p all -s 172.22.0.0/16 ! -o bridge-ps1 -j SNAT --to-source {IP-ADDRESS}

docker run --rm --network bridge-ps1 byrnedo/alpine-curl http://www.myip.ch
validate IP matches

screen -S presearch

docker stop presearch-node ; docker rm presearch-node ; docker stop presearch-auto-updater ; docker rm presearch-auto-updater ; docker run -d --name presearch-auto-updater --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --interval 300 presearch-node ; docker pull presearch/node ; docker run -dt --network bridge-ps1 --name presearch-node --restart=unless-stopped -v presearch-node-storage:/app/node -e REGISTRATION_CODE={REGISTRATION-CODE} presearch/node ; docker logs -f presearch-node
ctrl-a d

validate reboot works properly

iptables troubleshooting

iptables -t nat -v -L POSTROUTING -n --line-number

iptables -t nat -D POSTROUTING {line-number}

This article was updated on 2023-08-03

I'm nabeards. I'm a full stack JavaScript developer. I travel full time, a.k.a., Professional Wanderer, a.k.a., Digital Nomad.