how can i disable ip forwarding from ipv6 to ipv4

Myra Sewitz asked:

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. from ipv6 to ipv4 takes place.

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

curl: (45) bind failed with errno 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.

please help me

My answer:


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,,,

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.