I believe here we are only pushing a route for metadata but no default route.
I did not try yet, which part was necessary: unsetting the subnet gateway and/or using the router dhcp option (as empty). Please give it a try. I hope it works for you as a well.
I will link to the openstack client bug from here when I opened it. But until then neutron client should work.
It seems to me I can get neutron to not push a default route.
The subnet gateway actually can be unset. The API allows is:
https:/ /docs.openstack .org/api- ref/network/ v2/?expanded= create- subnet- detail# create- subnet
"To specify a subnet without a gateway, set the gateway_ip attribute to null in the request body."
With neutron client you could (and still can though neutron client is deprecated) leave the subnet gateway unset:
neutron subnet-create NET CIDR --no-gateway
I believe it is a bug of openstack client that leaving the gateway unset is not possible. I will open another bug report for that.
But if I do that and set the port's dhcp option 'router' to empty then I believe no default route is pushed:
openstack network create net0 value=, ip-version= 4
neutron subnet-create net0 10.0.4.0/24 --name subnet0 --no-gateway
openstack port create port0 --network net0
openstack port set port0 --extra-dhcp-option name=router,
openstack server create --flavor ds1G --image u1804 --nic port-id=port0 --wait vm0
Then I log in to this vm and inside:
# dhclient ens2
and in parallel I see this dhcp reply:
# tcpdump -n -vvv -i ens2 port 67 or port 68
Client- Ethernet- Address fa:16:3e:ac:bd:06
Vendor- rfc1048 Extensions
DHCP- Message Option 53, length 1: ACK
Server- ID Option 54, length 4: 10.0.4.1
Lease- Time Option 51, length 4: 86400
Subnet- Mask Option 1, length 4: 255.255.255.0
Domain- Name-Server Option 6, length 4: 10.0.4.1
Domain- Name Option 15, length 14: "openstacklocal"
Hostname Option 12, length 14: "host-10-0-4-55"
Classless- Static- Route Option 121, length 9: (169.254. 169.254/ 32:10.0. 4.1)
...
10.0.4.1.67 > 10.0.4.55.68: [udp sum ok] BOOTP/DHCP, Reply, length 333, xid 0xbc39bb14, Flags [none] (0x0000)
Your-IP 10.0.4.55
Server-IP 10.0.4.1
Magic Cookie 0x63825363
RN Option 58, length 4: 43200
RB Option 59, length 4: 75600
BR Option 28, length 4: 10.0.4.255
MTU Option 26, length 2: 1450
END Option 255, length 0
I believe here we are only pushing a route for metadata but no default route.
I did not try yet, which part was necessary: unsetting the subnet gateway and/or using the router dhcp option (as empty). Please give it a try. I hope it works for you as a well.
I will link to the openstack client bug from here when I opened it. But until then neutron client should work.