1

On a dedicated server with an hypervisor as host and Fedora 20 as guest, I successfully used the following commands in the guest VM to enable network with a IP failover:

ip route add <gateway>/32 dev <interface> src <IP failover>
ip route add default via <gateway> src <IP failover>
  1. How could I convert these commands in the /etc/sysconfig/network-scripts/ifcfg-<interface> file?
  2. By security, I must send a DHCP request to make the router identify the MAC address and be authorized on the network. Manually, I did that just running dhclient.

How can I automate this process at boot time?

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
Ethel
  • 11
  • 1

1 Answers1

0

You can't put commands into the ifcfg-ethX files because they're just that -- config files. You can, however, use ifup/down post scripts to do what you want to achieve. The ifup/ifdown scripts all will execute, if exists and is executable, /sbin/ifup-local and /sbin/ifdown-local. In these scripts you will be able to put both your ip route add commands, and the call to dhclient to do your MAC authorization.

For example, I use /sbin/ifup-post to change some priorities on IPv6 addressing once the interfaces have been brought up. These can simply be bash scripts, since the rest of the ifup/down sequence is also a bash script.

Some variables that will be available to you inside of these scripts will be the device that's been brought on/offline $DEVICE, the IP address $IPADDR amongst other things. Scan through /etc/sysconfig/network-scripts/ifup-post and /etc/sysconfig/network-scripts/ifdown-post to get a general idea of what information is available. The /sbin/ifXX-local script calls are right at the very end of these scripts.

dannosaur
  • 983
  • 5
  • 15
  • wouldn't an ifroute-ethx be the logical place to put persistent routes? ifup-post is debien way. rhel way is ifroute, I think – Dani_l Jul 19 '14 at 09:45
  • In theory, yes -- if that's all you're doing. Question 2 mandates that he must fire `dhclient` to authorize his device on the network once the interface comes up. The only way to do this is via an `ifup-post` script. He could still put his static routes in `/etc/sysconfig/network-scripts/route-`, but must still use `ifup-post` to fire `dhclient`. – dannosaur Jul 19 '14 at 11:17
  • Not knowing the details of the security setup, I can't really comment on using dhclient - it's not clear from the question if dhcp or static IP is used later on. If the later, dhcp could be configured in ifcfg-ethx and be done. Even if not, if "I" had to maintain that system in the future, I would first look for routes in the "native" place for them. – Dani_l Jul 19 '14 at 11:24
  • I agree. I'm the exact same. If I can find a way to centrally manage the network configuration, I'll do it. At least it gives me the power to replicate the configuration exactly to other machines, and/or update the entire network from a single location then force propagation. – dannosaur Jul 19 '14 at 11:32