Closed samsunix closed 1 year ago
Hi samsunix,
it tries to interpret your environment variable as executable. Here is how to use systemd unit files with environment variables https://flatcar-linux.org/docs/latest/setup/systemd/environment-variables/ Hope that helps.
Hi JsBergbau and thank you for the reply and tips.
I got it now launching with the hint you gave me, thank you. Script runs but unfortunately my original problem still remains 🗡️
valheim.service now:
[Unit]
Description=Valheim Dedicated Server
After=5mindelay.service
[Service]
Environment=BIND_INTERFACE=enp3s0 DNS_OVERRIDE_IP=8.8.8.8 LD_PRELOAD=/home/steam/BindToInterface/bindToInterface.so
ExecStartPre=/bin/rm -f /home/steam/valheim/start_server.sh
ExecStartPre=/bin/cp /home/steam/conf/start_server.sh /home/steam/valheim/start_server.sh
ExecStart=/bin/bash /home/steam/valheim/start_server.sh
WorkingDirectory=/home/steam/valheim/
StandardOutput=inherit
StandardError=inherit
User=steam
[Install]
WantedBy=multi-user.target
No error messages and at least some of the program ports are on correct device but...
sudo netstat -peanut
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 25239 741/sshd: /usr/sbin
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 102 22063 655/systemd-resolve
**tcp 0 0 192.168.0.7:36681 155.133.230.34:27035 ESTABLISHED 1001 31280 1746/./valheim_serv**
tcp 0 0 192.168.0.6:22 192.168.0.11:51251 ESTABLISHED 0 25296 834/sshd: steam [pr
tcp 0 0 192.168.0.6:22 192.168.0.11:52243 ESTABLISHED 0 30214 1412/sshd: steam [p
tcp 0 352 192.168.0.6:22 192.168.0.11:52139 ESTABLISHED 0 30877 1334/sshd: samsunix
tcp 0 0 192.168.0.6:22 192.168.0.11:51371 ESTABLISHED 0 28955 1155/sshd: samsunix
tcp 0 0 192.168.0.6:56961 155.133.230.34:27032 ESTABLISHED 1001 28851 815/./ProjectZomboi
tcp6 0 0 :::27015 :::* LISTEN 1001 25464 815/./ProjectZomboi
tcp6 0 0 :::22 :::* LISTEN 0 25241 741/sshd: /usr/sbin
udp 0 0 0.0.0.0:16261 0.0.0.0:* 1001 25458 815/./ProjectZomboi
udp 0 0 127.0.0.53:53 0.0.0.0:* 102 22062 655/systemd-resolve
udp 0 0 192.168.0.7:68 0.0.0.0:* 101 25046 653/systemd-network
udp 0 0 192.168.0.6:68 0.0.0.0:* 101 27575 653/systemd-network
**udp 0 0 0.0.0.0:2458 0.0.0.0:* 1001 31267 1746/./valheim_serv
udp6 0 0 :::2457 :::* 1001 33099 1746/./valheim_serv**
For some reason I can't still connect the server.
C:\Users\samul>telnet 192.168.0.7 2457
Connecting To 192.168.0.7...Could not open connection to the host, on port 2457: Connect failed
Am I total idiot, what I am missing here?
Are you trying that your server listens only on 192.168.0.7?
BIND_INTERFACE is only intended for outgoing traffic not for listening traffic since most programs allow you to specify the listening address like 127.0.0.1, 0.0.0.0 for all interfaces or in your case 192.168.0.7.
But based on your netstat output valheim_serv listens only on udp. You can't connect with telnet to UDP ports. You could try with nc (netcat), but without knowing wheter the server will respond anything without the right packets sent you can't really test that.
You can have a look at the micrsocks example https://github.com/JsBergbau/BindToInterface#microsocks
In your case I would first try to get it running without systemd, because systemd behaves sometimes special/different.
I am trying to setup it so both programs are using different interfaces
Valheim should listen and send trough 192.168.0.7 and Zomboid 192.168.0.6 (because two gigabit ethernet's so why not? -right?)
Currently I am able to join Valheim server but now Zomboid is out of game:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 102 22016 653/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 26343 731/sshd: /usr/sbin
tcp 0 64 192.168.0.6:22 192.168.0.11:65460 ESTABLISHED 0 29746 1195/sshd: samsunix
tcp 0 0 192.168.0.7:38843 155.133.230.50:27031 ESTABLISHED 1001 26406 813/./ProjectZomboi
tcp 0 0 192.168.0.7:37599 155.133.230.50:27019 ESTABLISHED 1001 29703 715/./valheim_serve
tcp6 0 0 :::22 :::* LISTEN 0 26345 731/sshd: /usr/sbin
tcp6 0 0 :::27015 :::* LISTEN 1001 28166 813/./ProjectZomboi
udp 0 0 0.0.0.0:2457 0.0.0.0:* 1001 28896 715/./valheim_serve
udp 0 0 0.0.0.0:16261 0.0.0.0:* 1001 28160 813/./ProjectZomboi
udp 0 0 127.0.0.53:53 0.0.0.0:* 102 22015 653/systemd-resolve
udp 0 0 192.168.0.6:68 0.0.0.0:* 101 26210 651/systemd-network
udp 0 0 192.168.0.7:68 0.0.0.0:* 101 26197 651/systemd-network
udp6 0 0 :::2456 :::* 1001 27635 715/./valheim_serve
That said, it seems I am able to join zomboid also but only by local ip 192.168.0.6
Most likely because of this line: tcp 0 0 192.168.0.7:38843 155.133.230.50:27031 ESTABLISHED 1001 26406 813/./ProjectZomboi
Got it working. I had wrong interface name on my zomboid.service ^-^'
Thank you for the help and extended support.
I'm glad that it works as intented.
BTW: If you're only using it because you have two NICs you should consider using NIC-Teaming / bonding. Depeding on your distribution there are multiple ways to accomplish this. For ubuntu server Iused this tutorial https://getlabsdone.com/how-to-configure-bonding-using-netplan/
Hi and thank you, I been looking something like this for a while. I am trying to run this as part of service:
But output doesn't seem promising: