How to get rid of 169.254.0.0 route?
This is from route -n
command.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.x 0.0.0.0 UG 600 0 0 <wifi>
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 <wifi>
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 <wifi>
I have tried:
1) disabled ufw and ran from the terminal(same with ufw enabled):
sudo route del -net 169.254.0.0 gw 0.0.0.0
got SIOCDELRT: Invalid argument
2) commented link-local 169.254.0.0
line in the /etc/networks
file and rebooted.
3) disabled avahi-deamon
since it seems to be related.
Nothing works, I use static IP but always when I connect to my router and run route -n command
it appears there. So. do you guys have any other ideas?
UPDATE:
Thanks to the answer below I have looked into avahi-autoipd
manpage and managed to find a solution. To remove the route:
sudo route del -net 169.254.0.0 netmask 255.255.0.0 dev <interface> metric 1000
where <interface>
is your network interface, such as wlan0 for example. However, this would only remove it until next network association because it spawns all over again. So to make it permanent, you need to modify the /etc/network/if-up.d/avahi-autoipd
file, the root of the spawning.
I commented out the final part of the code:
#if [ -x /bin/ip ]; then
# route already present?
#ip route show | grep -q '^169.254.0.0/16[[:space:]]' && exit 0
#/bin/ip route add 169.254.0.0/16 dev $IFACE metric 1000 scope link
#elif [ -x /sbin/route ]; then
# route already present?
#/sbin/route -n | egrep -q "^169.254.0.0[[:space:]]" && exit 0
#/sbin/route add -net 169.254.0.0 netmask 255.255.0.0 dev $IFACE metric 1000
#fi
Solution 1:
There is nothing at all you need to do. The 169.254.0.0 route is typically present for everyone with internet connectivity. Here is the route information from my machine:
chili@T440p:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 600 0 0 wlp3s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlp3s0
192.168.0.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0
Please see: https://serverfault.com/questions/132657/where-route-to-169-254-0-0-comes-from
Especially see:
The 169.254.0.0/16 network is used for Automatic Private IP Addressing, or APIPA. If a DHCP client attempts to get an address, but fails to find a DHCP server after the timeout and retries period it will randomly assume an address from this network. This allows communication with hosts that have failed to obtain a DHCP address.
In short, the entry is entirely normal.
Solution 2:
You're right in your assumption that this route comes from avahi.
Disabling avahi-deamon
may not be enough since your DHCP client may be configured to use avahi-autoipd
in order to set a Link-local IP when the DHCP request fails.
There are several things I would try:
- add a line
deny-interfaces=wifi
(that's the name of your network interface, right?) in/etc/avahi/avahi-daemon.conf
- since you're using a static IP anyway, disable your DHCP client (
dhcpcd
?) - as this answer suggests, you can simply uninstall
avahi-daemon
. Sure, this amounts to killing a fly with a steamroller, but it'll work