RHEL 7.4 adding permanent static route error

Paolo Sestini asked:

I need to add a static route to my system.
I can do it with no problem at the command line with:

ip route add 10.126.2.0/23 via 10.126.1.5 src 10.2.14.205

To make it permanent I created the /etc/sysconfig/network-scripts/route-tun10
file with the following line:

10.126.2.0/23 via 10.126.1.5 src 10.2.14.205

But when I run ifup tun10 command (even after a ifdown tun10 command) I get the following error:

".ror: inet address is expected rather than "10.2.14.205

Could somebody, please, help me understand and solve the problem?

Thanks.
Paolo.

My answer:


It looks like your route-tun10 file has a stray carriage return at the end of the line. This is usually because the file was created on Windows and then copied to the system. It’s a good idea to avoid Windows text editors due to their line endings causing confusion on Linux systems, unless you can explicitly configure the text editor to use Unix line endings.

To fix the problem with this file, run dos2unix on it, which will remove the carriage returns and leave only newlines. For example:

sudo dos2unix /etc/sysconfig/network-scripts/route-tun10

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.