-1

I have IPv4 and ipv6 addresses on my network card, when I send a request with curl I want only the respective IPv4 or IPv6 to be used and no fallback e.g. When IPv6 to IPv4 takes place.

curl --interface XXXX: c020: XXXX: e601: XXXX: 596c: XXXX: db97 http://ip4only.me/api/

curl: (45) bind failed with error 22: Invalid argument

curl -x http: // [2603: XXXX: 8003: e601: XXXX: 596c: XXXX: db97]: 8080 http://ip4only.me/api/

IPv4,130.XX.XXX.81

I would like to receive an error if the site only accepts IPv4 addresses, as with the --interface variant.

IPv4 forwarding is switched off.

ubuntu @ app-1: ~ $ sudo grep -r ip_forward / etc
/etc/ufw/sysctl.conf:#net/ipv4/ip_forward=1
/etc/sysctl.conf:#net.ipv4.ip_forward=1

Apparently, a forwarding takes place anyway when I send it with a port.

Dave M
  • 4,514
  • 22
  • 31
  • 30

1 Answers1

1

You can override which IP protocol stack is used with the -4 and -6 options, which restrict it to IPv4 or IPv6 respectively. Consider:

$ curl -6 http://ip4only.me/api/
curl: (6) Could not resolve host: ip4only.me

$ curl -4 http://ip4only.me/api/
IPv4,198.51.100.84,Remaining fields reserved for future use,,,
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • I know but I want the server based no forwarding does not take place via a curl command – Myra Sewitz Sep 24 '21 at 11:10
  • @MyraSewitz Sorry, I don't understand what you mean. There is no forwarding here already. Do you mean something else? – Michael Hampton Sep 24 '21 at 13:58
  • I would like if an IP V6 address was set in tcp_outgoing_address that then only iPv6 without IP V4 fallback is used in my case I always get an iPv4 fallback if the server only accepts IP V4 and I want to switch it off I would like to receive an error message when I with an iPv6 address I want to connect to a server that only accepts IP V4 addresses – Myra Sewitz Sep 24 '21 at 14:09
  • @MyraSewitz I'm still having some trouble understanding your comments. I think you want to receive an error if you try to connect via IPv6 but the web site only supports IPv4. The command posted above already does this. If there is something else, please be specific. You might also want to ask a fluent English speaker to help you compose your comments. – Michael Hampton Sep 24 '21 at 14:17
  • Thanks for helping but i dont think i will get a solution here therefore i will close the question – Myra Sewitz Sep 24 '21 at 15:18
  • I will use squid proxy, I would like if an IP V6 address was set in tcp_outgoing_address that then only iPv6 without IP V4 fallback is used in my case I always get an iPv4 fallback if the server only accepts IP V4 and I want to switch it off I would like to receive an error message when I with an iPv6 address I want to connect to a server that only accepts IP V4 addresses – Myra Sewitz Sep 24 '21 at 15:21
  • @MyraSewitz Huh? You asked about curl, not squid. If you asked about squid at the beginning then maybe this would all make some sense and you could get a solution faster. – Michael Hampton Sep 24 '21 at 15:33
  • Sry for that can you help me – Myra Sewitz Sep 24 '21 at 16:20