0

how to use 2302:1400:3010:3731:0:1/96 subnet for outbound connection from linux?

I'm trying to use something like this curl --interface 2302:1400:3010:3731:0:1:5fff:8 ifconfig.co in GCP VM

this is working if I add with ip -6 addr add 2302:1400:3010:3731:0:1:5fff:8/128 dev ens4, but I want to use all address of 2302:1400:3010:3731:0:1/96 or at least 2302:1400:3010:3731:0:1/112

but if I add with ip -6 addr add 2302:1400:3010:3731:0:1:5fff::/112 dev ens4, curl is not working, giving error with (99: Cannot assign requested address)

  • 2
    Who gave you that IP address? – vidarlo Jan 22 '22 at 08:29
  • Are you trying to add VM's to a primary network interface or secondary network interface? Make sure the IPv6 is enabled in the subnet first and next in the VM. Refer this [documentation](https://cloud.google.com/vpc/docs/using-vpc#subnet-enable-ipv6) for more information on enabling IPv6 and refer this [documentation](https://cloud.google.com/vpc/docs/vpc#ipv6-addresses) for details on IPv6. – Goli Nikitha Jan 22 '22 at 13:18
  • @GoliNikitha as I stated above, if I use /128 its working fine, but I can't a way to use any ip in that range, its enabled in subnet, vm as /96 to main interface. I followed same links what you shared. – Chandan Pasunoori Jan 23 '22 at 01:53
  • @vidarlo its in GCP – Chandan Pasunoori Jan 23 '22 at 01:53

1 Answers1

1

After many tries with different options, finally adding addr and route along with enabling net.ipv6.ip_nonlocal_bind doing trick

ip add add local 2302:1400:3010:3731:0:1/96 dev lo
ip route add local 2302:1400:3010:3731:0:1/96 dev ens4
sysctl net.ipv6.ip_nonlocal_bind=1

Reference: https://serverfault.com/a/971732/225853

make this question duplicate :(