-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPv4 prefix isn't being registered #109
Comments
It seems #58 is related, it's mentioned there that I could configure the extra addresses with drop in config files? |
I've worked out a bit more, I've got this script in the user-data cloud-init script. TOKEN=$(curl -s -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" "http://169.254.169.254/latest/api/token")
function imds () {
curl -f -s -w "\n" -H "X-aws-ec2-metadata-token: ${TOKEN}" "http://169.254.169.254/${1}"
}
for mac in $(imds "latest/meta-data/network/interfaces/macs")
do
mac=${mac%/} # remove trailing slash
if pfx=$(imds "latest/meta-data/network/interfaces/macs/${mac}/ipv4-prefix")
then
# determine the interface name from the mac address
# it is in the line before the mac address in the output of
# `ip addr`
iface="$(ip addr | grep -B1 $mac | head -1 | cut -d: -f2 | tr -d ' ')"
# get the netmask (the number after the /)
mask="$(echo $pfx | cut -d/ -f2)"
# get the last octet of the address
base="$(echo $pfx | cut -d/ -f1 | cut -d. -f 4)"
# get the first 3 octects of the address
net="$(echo $pfx | cut -d/ -f1 | cut -d. -f1,2,3)"
# generate each possible address in the prefix
# 32 - mask gives us the number of bits available for the host part of the address
# 2**(bits) gives us the number of addresses in that range
# each address will then be ${net}.${base + i}
# $(( base + i )) is the bash expansion to evaluate maths expressions
for ((i=0; i < 2**(32-mask); i++))
do
# The format for the .conf file is
# [Address]
# Address=1.2.3.4/24
#
echo -e "[Address]\nAddress=${net}.$((base + i))/24\n"
done > "/etc/systemd/network/70-${iface}.network"
fi
done
systemctl restart systemd-networkd This sets up the ip addresses based on the configuration at boot time. I'm not sure how I could make it adapt to runtime configuration changes, such as a new ENI being added or updated. I think adding a udev rule is the right approach but I'm not sure what event to listen to and if systemd-networkd is still the right configuration to modify from there. |
Hi @dlim201 I wouldn't know how to run the version 1 branch. I'm using Amazon Linux 2023 as AL2 is approaching end of life so I don't want to build anything new on it. We had tested this earlier on AL2 when examining if prefixes would work for us. We had this in the user script to enable it then:
|
Apologies if this isn't the correct place to ask this, I'm having trouble finding much documentation.
I'm running an Amazon Linux 2023
t4g.nano
instance with the AMIami-07832e309d3f756c8
(inus-east-1
) which has:installed. I'm trying to work out how to get the IPv4 prefix delegation to be registered with the second network interface.
This is the configured interfaces on boot:
I also have a
10.6.70.32/28
prefix on the secondens6
interfacePining an address in the
/28
on the machine doesn't work from another instance or on the instance itself. However if I manually add an address to the interface using:Then I can use ping those addresses.
I've read through most of setup-policy-routes.sh and lib.sh and it looks like it should be generating routes for the prefix.
It logs that it checks the IMDS endpoint for
ipv4-prefix
on that interface so I think it should be generating routes for it.Is there any setting I should be changing to get it to use them?
The text was updated successfully, but these errors were encountered: