I have a problem where I need to manually set up a route on Ubuntu 18.04 during the init (ram) process. I cannot use any of the new networking tools, only Busybox is available.
The routing table should looks like this:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.31.1.1 0.0.0.0 UG 100 0 0 ens3
172.31.1.1 0.0.0.0 255.255.255.255 UH 100 0 0 ens3
The host is a VPS with an IP of 95.xx.xx.xx, so the gateway IP is not on the same network. I can't figure out what command to build the above table with. I get various SIOCADDDRT
errors with everything I try.
Here's what I've tried so far:
> route add default gw 172.31.1.1
SIOCADDDRT: Network uncreachable
> route add default gw 172.31.1.1 via 0.0.0.0
..invalid format
> route add 172.31.1.1 gw 0.0.0.0
SIOCADDDRT: Invalid argument
> route add 0.0.0.0 gw 172.31.1.1
SIOCADDDRT: Network uncreachable
> route add default gw 0.0.0.0
SIOCADDDRT: Invalid argument
Is there any way to make this work with Busybox? Or any other way to make it happen inside initram?
On your desired output in flags, 'G' indicates a gateway, and 'H' represents a host. Hence for the
0.0.0.0
output you are trying to create for the route, its not really used.To add a host IP to the interface that will generate the same output: