how to add network route while in debian install

ehabehab Content Writer
edited April 2021 in Help

hi

i was installing debian and was faced with a external gateway that can only be added using a route either in network/interfaces or by command line.

in the install i can exit to shell and set up the network but when i exit its all lost.

any help would be appreciated
Thanks
ejab

«1

Comments

  • I had faced this while installing Debian from iso , had used VNC and added the IP and routes but they were persistent and not lost with mixed response
    One one VPS they were persistent/saved first time and on second one they got saved after 3 attempts so probably try again

  • ehabehab Content Writer
    edited April 2021

    you mean you [ exit to shell ] then add the interface file exit then repeat multiple times?

  • @ehab said:
    you mean you [ exit to shell ] then add the interface file exit then repeat multiple times?

    What i did was
    Added in shell , saved , restart still no network
    Again VNC , shell , add network , restart and i am pretty sure saved it correctly
    For one VPS I got network in 3rd attempt on another file got saved in first and got network

    Thanked by (1)ehab
  • ehabehab Content Writer

    i am talking about this shell

  • I have never needed to do this myself, but here's what I would try.

    1. In the Debian installer boot menu, start Expert install (Advanced options -> Expert install).
    2. Go through these steps (some of them will not be visible until you complete the previous ones).
      • Detect and mount CD-ROM
      • Load installer components from CD
      • Detect network hardware
      • Configure the network
    3. Now choose Execute a shell and configure your route using the ip route ... command.
    4. Check that the host/network is actually reachable using ping or whatnot.
    5. Exit the shell and continue with the installation (do not reboot before continuing, that would of course lead to the configuration being lost).

    If you also want to configure the static route for the installed system while it's still being installed, you will need to edit the configuration files in /target/etc/network as the dialog upon launching of the shell suggests. The /target directory will only exist after the disks have been partitioned, and the base system installed; either way, I'd do these edits at the very end of the installation so that you can be sure no step of the installation will overwrite your changes.

    Thanked by (2)ehab miu
  • edited April 2021

    Well i used VNC from the provider CP and added the entries for the network and that worked . Did not use this shell but finished the installation

  • Last time I had this I just finished the install without connectivity then added the specific network config once installed and modified the apt lists to use the correct address. apt-get update and the add anything missing that wasn't installed the first time.

  • Yes exact same what i did and ran netselect-apt for closest mirror

  • You can press Ctrl+Alt+F2 or F3 to get to a terminal, but I am not certain if the ip route commands are available (it's usually a BusyBox-like or basic sh prompt, no bash).

    Thanked by (1)yoursunny

    Cheap dedis are my drug, and I'm too far gone to turn back.

  • ehabehab Content Writer

    @rhinoduck said:
    4. Check that the host/network is actually reachable using ping or whatnot.

    yes

    1. Exit the shell and continue with the installation (do not reboot before continuing, that would of course lead to the configuration being lost).

    network dialog still displays gateway is not reachable.

  • ehabehab Content Writer

    @Mr_Tom said:
    Last time I had this I just finished the install without connectivity then added the specific network config once installed and modified the apt lists to use the correct address. apt-get update and the add anything missing that wasn't installed the first time.

    I am doing a net install, selecting do not configure network at this time does not continue.

  • ehabehab Content Writer

    @CamoYoshi said:
    You can press Ctrl+Alt+F2 or F3 to get to a terminal, but I am not certain if the ip route commands are available (it's usually a BusyBox-like or basic sh prompt, no bash).

    i am using html vnc and no keyboard options.

    Thanked by (1)isunbejo
  • @ehab said: I am doing a net install, selecting do not configure network at this time does not continue.

    Odd. I only have the netinstall ISO uploaded on the proxmox node that has an "odd" network setup and need a pointtopoint setup, so there must be a way to continue without networking?

  • ehabehab Content Writer
    edited April 2021

    @Mr_Tom said:
    Odd. I only have the netinstall ISO uploaded on the proxmox node that has an "odd" network setup and need a pointtopoint setup, so there must be a way to continue without networking?

    i boot with ipxe , i do setup the ip,gateway then i chain the ipxe file , it start by try to configure the network.
    maybe i google skip network setup in the pxe file if it exists.

  • Aah I was just using the netinstall ISO via VNC.

  • ehabehab Content Writer

    if i skip the network, i get stuck in loop miror

  • edited April 2021

    @CamoYoshi said: You can press Ctrl+Alt+F2 or F3 to get to a terminal, but I am not certain if the ip route commands are available (it's usually a BusyBox-like or basic sh prompt, no bash).

    They are.

    @ehab said: network dialog still displays gateway is not reachable.

    Then I see I was just restating what was already obvious to you. This is indeed odd, I've never run into this myself. Just out of curiosity, is this IPv4 or IPv6?

    As more of an offshoot, what I did run into was, for example, that FreeBSD does not like it at all when the gateway is in a different subnet (at least for IPv6), and it won't work even if you configure a static route to it. I wonder if something in the Debian installer perhaps has certain limitations/quirks like this. But this is pure speculation on my part.

  • ehabehab Content Writer

    Then I see I was just restating what was already obvious to you. This is indeed odd, I've never run into this myself. Just out of curiosity, is this IPv4 or IPv6?

    IPv4

    I wonder if something in the Debian installer perhaps has certain limitations/quirks like this. But this is pure speculation on my part.

    this is what i am thinking.

  • Hmm, just tried using a netinstall ISO with skipped network config and I get the following:

    Thanked by (2)ehab Not_Oles
  • @CamoYoshi said:
    You can press Ctrl+Alt+F2 or F3 to get to a terminal

    This is the correct answer.

    I am not certain if the ip route commands are available (it's usually a BusyBox-like or basic sh prompt, no bash).

    Yes, ip command is available by the time you get to network configuration page.

    @ehab said:
    i am using html vnc and no keyboard options.

    Not an excuse.

    sudo apt install gvncviewer
    gvncviewer 192.0.2.1:1
    

    The number after colon is "desktop number".
    It equals port number minus 5900.

    Thanked by (3)ehab Not_Oles miu

    Webhosting24 aff best VPS; ServerFactory aff best VDS; Cloudie best ASN; Huel aff best brotein.

  • Anyway, I tried a Debian 10 text installer on Nexril Dallas, booted via netboot.xyz.

    1. When the first menu (select a language) appears, press ESC key to get to the main menu.
    2. Select "execute a shell".
    3. Run command to setup IP address and routes, such as:

      ip addr add 192.0.2.2/24 dev ens3
      ip link set ens3 up
      ip route add default via 192.0.2.1
      echo 'nameserver 1.1.1.1' >/etc/resolv.conf
      
    4. Test connectivity:

      ping deb.debian.org
      
    5. Type exit to come back to the main menu.

    6. Select "choose language" to re-enter the installer.

    Note:

    • You need to know the correct IP address, subnet mask, and default gateway.

      • SolusVM will tell you.
      • Virtualizor will not tell you, but you can install a template and inspect the output of ip addr; ip -4 route; ip -6 route.
    • This works for IPv6-only server as well.

      • I used a similar procedure on WebHorizon Warsaw, where IPv6 and NAT IPv4 are on separate network interfaces. I selected the IPv6-only interface, and got it working this way.
    Thanked by (4)ehab Not_Oles miu psychoid

    Webhosting24 aff best VPS; ServerFactory aff best VDS; Cloudie best ASN; Huel aff best brotein.

  • @yoursunny said: The number after colon is "desktop number".

    If it's a remote system there might not be "direct" VNC access. Some VMs use VNC via a management panel relay host.

    Thanked by (2)ehab Not_Oles
  • Unless you've already solved the issue in a different way, here's something you can try.

    After digging a little bit deeper, I discovered that it seems to be a simple case of the Configure the network step doing input data validation where it requires the gateway to be from the same subnet. I believe the following is a way to work around that while minimising having to do a lot of additional manual changes.

    1. When entering values during the Configure the network step, leave the gateway value empty; it will not complain then.
    2. After the Configure the network step, go to a shell, and execute the following commands while substituting the placeholders with appropriate values.
    ip route add <gw_address> dev <iface_name>
    ip route add default via <gw_address> dev <iface_name>
    
    1. Test that you have outside connectivity, then exit the shell, and continue with the installation as you normally would (do NOT run the Configure the network step again).
    2. At the end of the installation, launch a shell again, and add the missing gateway and routes to the configuration files in /target/etc/network before rebooting.

    Step 4. can optionally be done after the reboot, but bear in mind that you will not have connectivity to anything outside of your subnet in the newly installed system until you do it.

    Thanked by (4)Falzo ehab Not_Oles miu
  • this happens, if you gateway is not on the same subnet like your IP, e.g. proxmox using routed bridges you'll not be able to setup the network via the dialog, because it doesn't make it a host route automatically, even if you specify 255.255.255.255 as subnet mask.

    as has been pointed out above, switch to a shell and use ip add/route to add what you need and get it working ;-)

    Thanked by (1)ehab
  • ehabehab Content Writer

    yeeees finally, i got to work; thanks to all who helped with ideas and special thanks to yoursunny , rhinoduck , Falzo

    the trick is to let it fail once without adding any value, choose to continue without if asked but must get back to main screen and enter shell and add ip,route like mentioned above.

    Thank you guys , i appreciated it.
    :)

    Thanked by (2)yoursunny CamoYoshi
  • edited April 2021

    A little bit more detail for those interested...

    This is where the error is coming from:
    https://salsa.debian.org/installer-team/netcfg/-/blob/1.172/static.c#L592
    https://salsa.debian.org/installer-team/netcfg/-/blob/1.172/netcfg-common.c#L1668

    It is not that having a gateway on a different subnet would not work, it is just that the Configure the network step will not let you configure the network that way. That's why I suggested "fooling" it by leaving the gateway value empty when going through this step, because that will shut the error up, and it will let you continue the installation; granted you still need to manually add the routes using the shell once you're through this step if you want to have network access during the installation.

    Just leaving the gateway field empty instead of leaving the whole Configure the network step out has the advantage of you having to only manually configure the routes in the installer shell, and only the routes and the gateway value in the new system, instead of having to manually do the whole static network configuration twice (once for the installer, and once for the installed system).

    Thanked by (2)ehab Not_Oles
  • miumiu
    edited April 2021

    @yoursunny said:
    Anyway, I tried a Debian 10 text installer on Nexril Dallas, booted via netboot.xyz.

    1. When the first menu (select a language) appears, press ESC key to get to the main menu.
    2. Select "execute a shell".
    3. Run command to setup IP address and routes, such as:

      ip addr add 192.0.2.2/24 dev ens3
      ip link set ens3 up
      ip route add default via 192.0.2.1
      echo 'nameserver 1.1.1.1' >/etc/resolv.conf
      
    4. Test connectivity:

      ping deb.debian.org
      
    5. Type exit to come back to the main menu.

    6. Select "choose language" to re-enter the installer.

    Note:

    • You need to know the correct IP address, subnet mask, and default gateway.

      • SolusVM will tell you.
      • Virtualizor will not tell you, but you can install a template and inspect the output of ip addr; ip -4 route; ip -6 route.
    • This works for IPv6-only server as well.

      • I used a similar procedure on WebHorizon Warsaw, where IPv6 and NAT IPv4 are on separate network interfaces. I selected the IPv6-only interface, and got it working this way.

    Great and completely written in short (y)

    and for checking of gateway i use also these commands route -n ; netstat -rn ; ip route show

    Good day and Goodbye

  • @miu said:
    and for checking of gateway i use also these commands route -n ; netstat -rn ; ip route show

    route and netstat are deprecated and no longer installed in newer systems.
    Use ip route and ss instead.

    Webhosting24 aff best VPS; ServerFactory aff best VDS; Cloudie best ASN; Huel aff best brotein.

  • @yoursunny said:

    @miu said:
    and for checking of gateway i use also these commands route -n ; netstat -rn ; ip route show

    route and netstat are deprecated and no longer installed in newer systems.
    Use ip route and ss instead.

    I think i am also quite deprecated so they are still ok for me also nowadays :-D
    But seriously - thanks for the info & update.

    Thanked by (1)yoursunny

    Good day and Goodbye

  • @yoursunny said:
    Anyway, I tried a Debian 10 text installer on Nexril Dallas, booted via netboot.xyz.

    1. When the first menu (select a language) appears, press ESC key to get to the main menu.

    Today I ran into this scenario when installing Ubuntu via netboot.xyz on a VPS that has an OVH failover IP, where the default gateway is in a different subnet.
    In my situation, DHCP can give IPv4 address and gateway, but the Ubuntu installer would reject the DHCP result and ask for manual configuration.

    The solution I gave a few days ago did not work: if I enter the IPv4 configuration first thing during installation, it would be overwritten when the installer executes DHCP, and then installation fails.
    Instead, I had to:

    1. Let the Ubuntu installer detect network and fail.
    2. Select "do not configure" network and proceed to entering hostname.
    3. When it reaches the next stage "select a mirror", I press ESC and start a shell.
    4. In the shell, I enter the network configuration with ip route commands.
    5. Then I exit the shell, and resume the installer at "select a mirror" step.

    The installed system would have a blank Netplan configuration, and I need to use VNC to configure network again.

    Webhosting24 aff best VPS; ServerFactory aff best VDS; Cloudie best ASN; Huel aff best brotein.

Sign In or Register to comment.