How to make Linode prefer configured static IP for outgoing connections?
Hello, I have recently got a /64 block for my Linode on Ubuntu 18.04 LTS and wanted to setup a static ip from that range with reverse DNS for it.
I have set up a static IP using a Linode guide, turned off automatic network setup and here's my /etc/netplan/01-eth0.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 172.105.70.26/24
- "2a01:7e01:e001:154::69/64"
gateway4: 172.105.70.1
gateway6: "fe80::1"
nameservers:
search: [members.linode.com]
addresses: [139.162.130.5, "2a01:7e01::5"]
After that ip -6 addr
shows
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2a01:7e01::f03c:92ff:fee2:2cbc/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 2591976sec preferred_lft 604776sec
inet6 2a01:7e01:e001:154::69/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::f03c:92ff:fee2:2cbc/64 scope link
valid_lft forever preferred_lft forever
My (really maturely selected) IP address is there. But default IP 2a01:7e01::f03c:92ff:fee2:2cbc
is still there too.
My DNS is managed my Mail-in-a-box, so I configured it to use 2a01:7e01:e001:154::69
as its public IP, and after running its setup again, I was able to set reverse DNS for that IP.
The only problem I still have, is that default IP is still there, and if I run ip -6 route get 2001:4860:4860::8888
it shows 2a01:7e01::f03c:92ff:fee2:2cbc
there.
I would like for my Linode to prefer static IP for outgoing connections and not default one. If default IP must be there, it's ok
UPD: I tried using accept-ra: no
and while it disabled the default IP, my linode loses connectivity, so it doesn't seem to be a solution
5 Replies
Curiosly, while tinkering with netplan, I managed to get a config that worked correctly right before a reboot.
By replacing gateway6 with routes with link-local I got correct results, but after reboot I couln't even ping ipv6 sites, silence and 100% packet loss.
Hey @truechaotic, I have a similar setup, and I got it to work by setting preferred_lft
to 0
for the default IPv6 address:
ip addr change 2a01:7e01::f03c:92ff:fee2:2cbc dev eth0 preferred_lft 0
Unfortunately, netplan does not allow setting this option (see [1]), but you can search the web for work-arounds (e.g., [2]).
[1] https://github.com/CanonicalLtd/netplan/pull/89
[2] https://bugs.launchpad.net/netplan/+bug/1803203
Thanks, @iliastsi. On my machine it worked, and request really went from IP I wanted. Strangely, after I ping6 Google, for example, default IP switches back.
I managed to make a netplan config that makes a persistent (between reboots) static IP and default route, in my case it looks like this
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 172.105.70.26/24
- "2a01:7e01:e001:154::69/64"
gateway4: 172.105.70.1
routes:
- to: "::/0"
via: "fe80::1"
from: "2a01:7e01:e001:154::69"
nameservers:
search: [members.linode.com]
addresses: [139.162.131.5, "2a01:7e01::5"]
The problem with my setup was that after I run MIAB setup script, system happily returns to using SLAAC address. I've posted a question to MIAB support forum. Maybe the setup script does something with system routing.
For now I wrote a shell script that changes a default route to one I need
ip route change "::/0" via "fe80::1" src "2a01:7e01:e001:154::69" dev eth0
curl -6 http://ip6only.me/api/
Right now I've semi-solved the problem by running the shell script to restore necessary IPv6 with cron.d
on @reboot
(while generally it works ok, strangely, first reboot after MIAB setup script didn't actually work, second reboot did)