How to make /etc/sysconfig/network/route-eth0 static

Hello,

I have a nethsever on my VMWare ESXI with OVH failover IP. Because of the infrastructure of OVH an static route is required. How can i make the above file stick in the filesystem?

Regards,

Jan

Just create all needed routes from the “Static route page”

Thanx Giacomo, i will try!

I’ve tried it but it is giving me a lot of trouble. The problem is that the moment i change anything in the static route, the whole machine becomes unreachable.

The static route has to be: (route-eth0)

xxx.xxx.xxx.254 dev eth0
default via xxx.xxx.xxx.254 dev eth0

Is there any other way to get this working?

Do you have a link to OVH documentation?
I may have a custom template to add support for this kind of setup.

1 Like

Hi @filippo_carletti,

The link to the OVH documentation BridgeCLient

Thanks in advance.

You need to create an action and link it to the static-routes-save event.
Here’s an example (adjust GATEWAY_VM and/or ethX) of what to write in /etc/e-smith/events/actions/ovh-route

#!/bin/sh

GATEWAY_VM=1.2.3.4

cat <<EOF >>/etc/sysconfig/network-scripts/route-eth0
$GATEWAY_VM dev eth0
default via $GATEWAY_VM dev eth0
EOF

Then link the action:
ln -sf ../actions/ovh-route /etc/e-smith/events/static-routes-save/S33ovh-route

If someone has an idea on how to integrate this “strange” setup in the default NethServer configuration, I’ll try to create a patch.

7 Likes

Thank u very much! It’s working like a charm.

3 Likes

Currently, this bug is always here, rules are removed after configuration changes…

You can see:

I can’t test my solution, but I trust feedback.
Could you give me access to a system where the problem is not fixed by my solution?

Thank you @ElKorbo for your support.
I applied my fix above and I think it’s working as expected.
Could you please confirm?

@filippo_carletti; Thanks for your intervention.
I have sent you an email, I have updated your script but in the test VM, it had not done because there are a lot of problems to see before, look here:

I have specified you the steps (but it does not work in Cockpit, look all screenshots which show you errors) in previous links.
The goal is to integrate without any commands for users (installer, and cockpit)


Recall, 2 weeks ago: I have done several tests, I give you the process:

1/ Bug with Cockpit Dashboard Network: Impossible to select the good IP Address / Netmask / Gateway ( Validation failed: IP address can't be the network or broadcast address. ) and other options (there is only IP address / Netmask / Gateway / Label (optional)).

2/ Bug with the core: The /etc/sysconfig/network-scripts/route-ensXX1 manually route file is removed, I have found to add a “manual” action but it must be “automatic”.

In ESXI, for the NethServer VM:
2 virtual network cards, one for WAN with MAC Address, one for LAN.

Install NethServer “without connection”, after it, connect with root account in console.

WAN:

db networks set ensXX1 ethernet role red hwaddr AB:CD:EF:GH:IJ:KL
 ipaddr XXX.XXX.XXX.XXX netmask 255.255.255.255 gateway YYY.YYY.YYY.254
 onboot yes bootproto none nm_controlled no userctl no
 ipv6init no peerdns no arp yes
 name ensXX1 defroute yes

signal-event interface-update

LAN:

db networks set ensXX2 ethernet role green
 ipaddr 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254
 name ensXX2

signal-event interface-update

There is a problem: ip route show:

default via 192.168.1.254 dev ensXX2
192.168.1.0/24 dev ensXX2 proto kernel scope link src 192.168.1.1

It is in the code:

I have done for ensXX1 configuration: defroute yes .

Now, I must to create an action, the ip route del default must not be in this file…

vi /etc/e-smith/events/actions/ovh-route

#!/bin/bash

ip route del default

GATEWAY_VM=YYY.YYY.YYY.254
INTERFACE=ensXX1

cat > /etc/sysconfig/network-scripts/route-$INTERFACE << EOF
$GATEWAY_VM dev $INTERFACE
default via $GATEWAY_VM dev $INTERFACE
EOF

ln -sf /etc/e-smith/events/actions/ovh-route /etc/e-smith/events/static-routes-save/S33ovh-route

chmod 0554 /etc/e-smith/events/static-routes-save/S33ovh-route
chown root:root /etc/e-smith/events/static-routes-save/S33ovh-route

signal-event interface-update

ip route show:

default via YYY.YYY.YYY.254 dev ensXX1
YYY.YYY.YYY.254 dev ensXX1 scope link
192.168.1.0/24 dev ensXX2 proto kernel scope link src 192.168.1.1

First Cockpit Dashboard connection:
→ FQDN
→ Organization settings
→ Updates

Could you please provide a diff or a pull request?
Code is easier to read for me, thank you.

It is not the first problem, the first problem is always here:
1/ Bug with Cockpit Dashboard Network: Impossible to select the good IP Address / Netmask / Gateway ( Validation failed: IP address can't be the network or broadcast address. ) and other options (there is only IP address / Netmask / Gateway / Label (optional)).

Please read all my messages, I will not repeat always same texts all times…

I think that you must to find a good solution to do not use “ip route del default” in the script.

But it is only a part of the solution, always all other specified problems.

Here for the route script, of course “GATEWAY_VM” and “INTERFACE” values must be auto detected.

#!/bin/bash

ip route del default

GATEWAY_VM=YYY.YYY.YYY.254
INTERFACE=ensXX1

cat > /etc/sysconfig/network-scripts/route-$INTERFACE << EOF
$GATEWAY_VM dev $INTERFACE
default via $GATEWAY_VM dev $INTERFACE
EOF

@filippo_carletti, @giacomo: I do not find the solution after several weeks of patience.
Can you solve it?

In mire @Jan_Runhart, @lorentedford has same problem too…

I’m sorry, I was waiting for your pull request.