I'm replacing a CentOS server with an Ubuntu 20 one. I need to duplicate the older servers routing configuration. The outputs of ip route show
and route
are not directly usable as inputs.
I'm a bit reluctant to hand-translate the output into route commands, because errors always creep in. Is there a better way?
I'm going to try a powershell script.
route
shows the current routing tables as a table with these columns: Destination,Gateway,Genmask,Flags,Metric,Ref,Use,IfaceSo I saved that output to a file, and copied it to the new host. I converted the raw output to a csv file by removing the first line, and replacing the spaces with a comma. I also replaced the device names with ones that matched on the new system. So my test route table might look like this:
The
route
command can produce unexpected errors when the route already exists. I also don't want the generated commands to run directly. So my PowerShell script looks like this:The generated commands are then: