Ubuntu server network problems – network down after reboot

I’ve experimented a strange situations a few days ago. After a few updates, my VPS became unreachable. Ifup command was throwing me errors – directory “/var/run/network” does not exists. After a few hours of researches, it seems that this is a problem that was solved back in 2008. Unfortunately, for some reasons – most probably because of updates the problem is back and i have no idea how to fix it – i’m not an expert. But, i tried the following thing that it’s working for me.

1. Create a .sh file with the following contents. Let’s name it network_check.sh

[prettify class=”bash”]

if [ ! -d “/var/run/network” ]; then

mkdir -p /var/run/network

sudo /etc/init.d/networking restart

sudo /etc/init.d/ssh restart

fi

[/prettify]

2. Create a cron to execute the script

[prettify class=”bash”]

*/1 * * * * root sh /PATH-TO-SCRIPT/network_check.sh

[/prettify]

As u can see i run the script every minute. You can set as much time as u want, but i like to be up and running immediate after reboot . Hope it helps someone 🙂