Static route without knowing the nexthop (linux)

27,515

The traffic has to go via your ISP's gateway. If eth3 has been assigned your public IP, then the default gateway address should be listed in your routing table:

ip route show table main

You then need to issue

ip route add 88.191.250.176 via <gatewayip> dev eth3

It should then work.

Share:
27,515

Related videos on Youtube

alci
Author by

alci

Updated on September 18, 2022

Comments

  • alci
    alci over 1 year

    I have an eth3 interface in a linux router, with an adsl modem. This adsl modem is in bridged mode, so the public IP is assigned to eth3 (say 11.22.33.44), and the modem is just not seen by my server.

    I want to define a static route to a specific IP (88.191.250.176) through eth3, but I don't have a nexthop to set:

    ip route add 88.191.250.176 dev eth3
    

    is accepted but does not work (packets never make their way out).

    ip route add 88.191.250.176 via 11.22.33.44 dev eth3
    

    Does not work either.

    If I set the modem in router mode, then I have a NATed address for the linux server (192.168.1.2), and IP address for the Adsl router (192.168.1.1), and I can do:

    ip route add 88.191.250.176 via 192.168.1.1 dev eth3
    

    Does work.

    Is it possible to define a static route through my adsl modem in bridged mode (first case), without having an explicit nexthop to give ?

    • Admin
      Admin over 11 years
      What is the IP of the interface? Is it static or what? When your ISP gave you the static, didn't they also give you the gateway? You need the gateway address. Using the device name as a route target mostly only works on serial links.
    • Admin
      Admin over 11 years
      Zoredache: you're right and you have enlightened me and my understanding of network configuration. Wish I could promote your comment as answer, as it really was what I was looking for. Now I have found the gateway address and can use it a 'via' parameter. Works like a charm.