systemd service error: no route to host after booting

2

I want my computer telnet to a remote machine (directly connected with Ethernet) when booting. I add feedback.service under /etc/systemd/system/

[Unit]
Description=Feedback relay daemon
Wants=network-online.target network.target
After=network-online.target network.target

[Service]
Type=oneshot
WorkingDirectory=/usr/local/
ExecStart=/usr/local/bin/feedback.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

feeback.sh:

#!/bin/bash
telnet 192.180.0.60 9000
exit 0

I used the option After=network-online.target to make sure this script would run after network configuration was done. However, systemctl status feedback still show No route to host error after reboot. It seems routing table was not set well at the moment feedback.sh was activated.

I already checked remote host is up and the network is accessible. I can ping remote host after reboot finished. I tried to add sleep 10 at top of the script then it worked well.

#!/bin/bash
sleep 10
telnet 192.180.0.60 9000
exit 0

But it's just a workaround. I need a real solution.

====================2019/08/22 Update============================

root@host# systemctl list-dependencies network-online.target
network-online.target
● └─networking.service

CodePurin

Posted 2019-08-20T02:38:18.487

Reputation: 21

What are you using to configure the network, NetworkManager or systemd-networkd or something else? What's the output of systemctl list-dependencies network-online.target? – filbranden – 2019-08-20T04:14:25.467

I use /etc/network/interface to config my internet systemctl list-dependencies network-online.target shows networking.service – CodePurin – 2019-08-22T05:07:47.883

No answers