Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I have a box which is running on Fedora 7. I have two Network Interface Cards eth0 and eth1. I intend to use eth0 for host connection to the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    3

    Permanently Adding Static Route is not persistant on reboot


    Hello,

    I have a box which is running on Fedora 7. I have two Network Interface Cards eth0 and eth1. I intend to use eth0 for host connection to the switch and eth1 for DRBD connection which is made to another similar machine via a crossover cable.

    Code:
    # Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express
    DEVICE=eth0
    BOOTPROTO=none
    HWADDR=00:12:79:A5:FB:2D
    ONBOOT=yes
    NETMASK=255.255.255.0
    IPADDR=192.168.1.71
    GATEWAY=192.168.1.1
    TYPE=Ethernet
    USERCTL=no
    IPV6INIT=no
    PEERDNS=yes
    
    # Intel Corporation 82541PI Gigabit Ethernet Controller
    DEVICE=eth1
    ONBOOT=yes
    BOOTPROTO=none
    HWADDR=00:1b:21:07:5a:e0
    NETMASK=255.255.255.0
    IPADDR=192.168.1.72
    TYPE=Ethernet
    USERCTL=no
    IPV6INIT=no
    PEERDNS=yes
    As the system is brought-up the default gateway is reached via eth1:

    Code:
    # route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
    192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
    169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
    In order to change the used interface to reach the default gateway from eth1 into eth0 I have created a file /etc/sysconfig/network-scripts/route-eth0 and added the following routes.

    Code:
    ADDRESS0=192.168.1.0
    NETMASK0=255.255.255.0
    GATEWAY0=192.168.1.1
    Once the file is created and saved, I restart the network service as follows:

    Code:
    # service network restart
    Shutting down interface eth0:                              [  OK  ]
    Shutting down interface eth1:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    SIOCGIFFLAGS: No such device
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth0:  RTNETLINK answers: File exists
                                                               [  OK  ]
    Bringing up interface eth1:
    As expected, this resulted in the default gateway to be changed to eth0.

    Code:
    # route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
    192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
    169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

    under assumption that this is going to be persistent on reboot, I reboot the system.

    To my surprise when the system is rebooted the default gateway goes back to eth1 and I need to restart the network service, in order for the default gateway to be changed to eth0.

    Can someone tell me what is going on and how I can fix this issue. I don't wish to use rc.local approach as this file gets over written easily when updating the system and I can lose connectivity to this remote machine.

    Thank you in advance for your help.

    Avestan
    Last edited by Avestan; 06-15-2012 at 01:58 AM.

  2. #2
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    Been a while since I ran Fedora, but I'll see what I can do.

    I forget why I needed to do it, but for a while on Fedora 7 or 8 I needed to add
    Code:
    service network restart
    to my rc.local file. It restarted networking during startup.

    Either that, or rc.M
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Have you thought about adding the gateway to ifcfg-eth1?

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •