Solved default gateway is in different subnet

dch

Developer
I have been trying out Scaleway's arm64 VMs with FreeBSD 14.2-RELEASE. As they don't offer official images, it's necessary to upload the qcow2 release image to their object store, convert it to a snapshot, turn the snapshot into an image from the command line, and finally boot the image.

Once that's done, FreeBSD comes up nicely, and a typical vtnet0 interface appears:

Code:
vtnet0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
        options=4c07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,TXCSUM_IPV6>
        ether de:00:00:8a:39:1d
        inet6 fe80::dc00:ff:fe8a:391d%vtnet0 prefixlen 64 scopeid 0x1
        inet6 2001:bc8:710:96ee:dc00:ff:fe8a:391d prefixlen 64 autoconf pltime 14400 vltime 86400
        media: Ethernet autoselect (10Gbase-T <full-duplex>)
        status: active
        nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>

IPv6 worked OOTB, with ifconfig_vtnet0_ipv6="inet6 accept_rtadv" but DHCP did not. These are the settings Scaleway provides:
  • IP: 163.172.143.183/32
  • gateway 62.210.0.1
I set up a static IP as usual, and was surprised to see that the default gateway is not in the same subnet - I did not know this was possible, how does FreeBSD know where to send packets to?

This approach doesn't work, in rc.conf.

Code:
ifconfig_vtnet0="inet 163.172.143.183/32"
defaultrouter="62.210.0.1"

Doing this manually:

Code:
root@a04:~ # ifconfig vtnet0 inet 163.172.143.183/32 add
root@a04:~ # netstat -4rn
Routing tables

Internet:
Destination        Gateway            Flags         Netif Expire
127.0.0.1          link#2             UH              lo0
163.172.143.183    link#2             UH              lo0
root@a04:~ # route add default 62.210.0.1
add net default: gateway 62.210.0.1 fib 0: Invalid argument
root@a04:~ #

Any suggestions?
 
see this ?
 
see this ?
Found something alike on StackExchange.
And, not tested though, what I can think of is that configuring static route to the given default gateway (not as default), configure given local IPv4 address as default gateway but route only to the same subnet and route any others to the static route.
Or (I have no experiences though) use BGP, considering the local network (virtually) as whole Internet? Possibly overkill and not sure it requires unique AS number or not.
 
see this ?
that is precisely what was required - thanks! I will try Stefano's one as well and see if that works too.

Code:
static_routes="meh"
route_meh="-net 1.2.3.4 -iface vnet0"
defaultrouter="1.2.3.4"
 
Back
Top