Function add

  • Add new route.

    Parameters

    • options: RouteAddOptions

      Parameters options to be passed down to ip.

    • globalOptions: GlobalOptions = {}

      Global parameters options that affects the command execution.

    Returns Promise<Command<RouteAddOptions>>

    Throws

    ParametersError - Throws when passed parameters are invalid.

    Throws

    CommandError - Throws when the executed command fails.

    Example

    Import module

    import { route } from 'iproute';
    

    Unicast type route (the default if not specified)

    await route.add({
    to: '10.0.0.0/24',
    via: {
    address: '192.168.56.1'
    }
    });

    Multipath route with load balance between devices

    await route.add({
    to: 'default',
    scope: AddressScopes.Global,
    nexthops: [{
    nexthop: true,
    dev: 'ppp0'
    },
    {
    nexthop: true,
    dev: 'ppp1'
    }]
    });

    A NAT route

    await route.add({
    type: RoutingTableTypes.Nat,
    to: '10.0.0.0/24',
    table: 300,
    via: {
    address: '192.168.56.1'
    }
    });

Generated using TypeDoc