New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No route found for IPv6 destination ff02::1:ff00:1 (no default route?) when running IPv6-only #4304
Comments
Thanks for you report. Does this patch fixes your issue:
|
Hey, sorry for delayed answer. No, this patch does not help as the IPv6 section is never reached, if there is at least one route in the IPv4 routing table. Which is almost always the case because of the loopback interface: >>> conf.route
Network Netmask Gateway Iface Output IP Metric
127.0.0.0 255.0.0.0 0.0.0.0 lo 127.0.0.1 1 |
That's a good point. We could check if the only IPv4 interface is the loopback, and move on to IPv6 if it is true. What do you think? |
That would work. Or we can just look for IPv4 default route, if it is not there look for IPv6 default route and if that is not there either, fall back to loopback. |
So I have created the proposed solution: diff --git a/scapy/interfaces.py b/scapy/interfaces.py
index f40f529e..73403098 100644
--- a/scapy/interfaces.py
+++ b/scapy/interfaces.py
@@ -372,11 +372,17 @@ def get_if_list():
def get_working_if():
# type: () -> NetworkInterface
"""Return an interface that works"""
- # return the interface associated with the route with smallest
- # mask (route by default if it exists)
- routes = conf.route.routes[:]
- routes.sort(key=lambda x: x[1])
- ifaces = (x[3] for x in routes)
+ # return the interface associated with the default route
+ # IPv4 default route is preferred, then IPv6 route shorter or equal than /8 or
+ # loopback as a fallback
+ default_routes_v4 = (x for x in conf.route.routes if x[1] == 0)
+ if conf.route6:
+ default_routes_v6 = (x for x in conf.route6.routes if x[1] <= 8)
+ default_routes_v6 = sorted(default_routes_v6, key=lambda x: x[1])
+ else:
+ default_routes_v6 = list()
+
+ ifaces = (x[3] for x in itertools.chain(default_routes_v4, default_routes_v6))
# First check the routing ifaces from best to worse,
# then check all the available ifaces as backup.
for ifname in itertools.chain(ifaces, conf.ifaces.values()): Unfortunately it does not work because |
Instead of considering the full IPv4 routing table, we only look for IPv4 default route and IPv6 routes shorter or equal /8 (for instance `2000::/3`). Since the `conf.route6` is not ready yet when we first run, we reload `conf.ifaces` after loading `route6.py`. This fixes secdev#4304 Signed-off-by: Ondřej Caletka <ondrej@caletka.cz>
Brief description
When running Scapy on IPv6-only host, it produces warnings every time it sends any data despite working normally.
Scapy version
2.5.0
Python version
3.10.12
Operating system
3.10.0-1160.102.1.el7.x86_64
Additional environment information
Running in an IPv6-only docker container based on Ubuntu
How to reproduce
Actual result
Expected result
Related resources
The routing table has an IPv6 default route. The issue lies in the fact the loopback gets selected as the default interface (
conf.iface
) because the selection algorithm of default interface is IPv4-only. Also even thougheth0
has some IPv6 addresses, they are not shown when there is no IPv4 address configured.Changing
conf.iface
manually toeth0
works around the issue. I failed to find a way how to do this automatically though, as it is apparently not possible to adjust this usingprestart.py
.The text was updated successfully, but these errors were encountered: