/sbin/ip route add … RTNETLINK answers: File exists

When starting opevpn I encountered strange issue. VPN was connecting but I could not access services behind it.
What I found in its log was:

Thu Oct 16 12:15:50 2014 /sbin/ip route add via
RTNETLINK answers: File exists

It turned out the newly added route was conflicting with other route (a leftover from messing up vpn-things).

First, I removed the conflicting rule:

sudo route del -net netmask

Then I manually added the route the vpn was trying to add (but I think it’s optional and simply restarting the VPN would do the thing)

/sbin/ip route add via


Starting on system startup and respawning apps with upstart in ubuntu


Following is an example config file for starting app on system startup and auto-respawning.
File name should be put in /etc/init, its name should end with .conf

The name of the task is derived from file name. For file name taskName.conf, the task is called taskName.

start on runlevel [2345]

description "your app description"

# Start a job as username, a member of usergroup
setuid username
setgid usergroup

# set required environments (what you normally do with export VARIABLE=VALUE)
env ENV_TO_SET = environment\ value

# run the app
exec /home/myuser/bin/myapp

# Restart the process if it dies with a signal
# or exit code not given by the 'normal exit' stanza.

# Give up if restart occurs 10 times in 90 seconds.
respawn limit 10 90


To start a task run:

$ sudo start taskName

And to stop it:

$ sudo stop taskName

More info: http://upstart.ubuntu.com/cookbook/


When you get some strange errors reading files, you might need to add an env which defines locale, e.g.:

env LC_ALL=pl_PL.UTF-8

For running java apps, remember to specify JAVA_HOME

setting up iptables to forward 80 (http) and 443 (https) to other ports

If you want to serve http content from application run by a non-root user, you can set up iptables to forward http and https ports to “user space ports”.

Setting up

Assuming your app uses port 8080 for http and 8081 for https, configure iptables as follows:

$ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
$ sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8081

Saving and restoring

Test the configuration and if it works save it, e.g. with:

sudo iptables-save > /etc/iptables/rules

Now you have to add reading iptables configuration on system startup.
If your network is configured manually you can add iptables-restore < /etc/iptables/rules to your /etc/network/interfaces:

auto eth0
iface eth0 inet dhcp
        pre-up iptables-restore < /etc/iptables/rules

If your /etc/network/interfaces is generated automatically, you can create a new file in /etc/network/if-pre-up.d/ with following content:


iptables-restore < /etc/iptables/rules
exit 0

Flash problems in ubuntu 12.04

To make flash plugin run well on ubuntu:

  • choose flashplugin-installer version of flash in chrome
  • invoke
    sudo add-apt-repository ppa:ubuntu-audio-dev/ppa; sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install linux-sound-base alsa-base alsa-utils linux-image-`uname -r` libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils linux-image-`uname -r` libasound2; killall pulseaudio; rm -r ~/.pulse*; sudo usermod -aG `cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'` `whoami`

The second one is the first step of: https://help.ubuntu.com/community/SoundTroubleshootingProcedure