Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Changing default route issues

    Hi all,

    I am trying to play around with routing and I have a symptom I do not quite understand.

    - A private network addressed
    - router1 - This router is the default gateway sits on the network as This machine also provides dhcp leases, dns and basic network services. It is directly connected to the internet via a second nic and iptables is used to nat the connection and provide internet connectivity to the network.
    - router2 - This sits on the network at This is also connected to the internet via a second ISP via an off the shelf router. Also has the ability to nat connections out to the internet via iptables and the off the shelf router.

    I am connected to a third machine on the network ( for arguments sake). The default route for the machine is I have a small script that goes to the internet (wget) and grabs the external IP from

    I run the test first time and get the external IP associate with the external nic on router1 as I expect. All good so far.

    Next I manually delete the default gateway on the client and add the new default gateway Route shows me the new gateway as I expect. I run my script again and I once again get the external IP associated with router1 and not that of router2.
    If I run a traceroute to for example, the route is shown via router2.

    Can anyone try to help me understand why changing the default gw on the client is not reflected in the wget command yet is in the traceroute?
    I don't profess to be a networking expert of any calibre so apologies if this is a stupid question.

    Many thanks.

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    The Keystone State
    Are you sure the first test results are not cached some where? What about your ARP table does it also get flushed?


    The adventure of a life time.

    Linux User #296285
    Get Counted

  3. #3
    And is your script IP based or URL based? If it's URL it will always point back to the designated IP in a name-server out there.

  4. $spacer_open
  5. #4
    Linux Newbie nplusplus's Avatar
    Join Date
    Apr 2010
    Charlotte, NC, USA
    You might check out this page: Tuning Linux IPv4 route cache | Vincent Bernat.

    In particular, checkout the output of the "ip route show cache" command.


  6. #5
    Thanks all for the pointers.
    @Lazydog - I did not flush the ARP tables. I will do some reading and try that next time.
    @gregr1969 - The script is using the URL for the IP service
    @nplusplus - I will have a read of that page

    I am away from the network for the next couple of weeks so it might take a while before I get to troubleshoot this any further.

  7. #6
    then that would explain your problem. DNS records point to a static IP unless they are dynamically assigned. You would need static routes to change the way it traces and your script would have to be based on IP NOT URL as URL uses DNS entries

  8. #7
    Just Joined!
    Join Date
    Mar 2007
    Melbourne, Australia
    This to me sounds like you have a proxy server in the network and its default route is via If both and are setup to do transparent proxying, or the client is configured to always use a proxy server, then changing the default gateway on the client will only affect non-proxy traffic!


Posting Permissions

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