Skip to content
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

bind_interface doesn't work, mosquitto only binds to localhost #2696

Open
l29ah opened this issue Nov 30, 2022 · 3 comments
Open

bind_interface doesn't work, mosquitto only binds to localhost #2696

l29ah opened this issue Nov 30, 2022 · 3 comments

Comments

@l29ah
Copy link

l29ah commented Nov 30, 2022

mosquitto-2.0.15 on Gentoo Lignux here. strace doesn't tell any hints on why doesn't it work. listener works but is unsuitable for dynamic IP addresses.

∞ grep -Ev '^#|^$' /etc/mosquitto/mosquitto.conf 
persistent_client_expiration 1y
bind_interface eth2
autosave_interval 1800
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
log_dest syslog
log_type information
allow_anonymous true
@nadav-bariks
Copy link

nadav-bariks commented Dec 1, 2022

also having problem with bind_interface
mosquitto-2.0.15 on ubuntu 20.04

running mosquitto from command using sudo

mosquitto.config is:

listener  8882
bind_interface enp3s0
protocol mqtt
allow_anonymous true

getting error:
1669877815: Error: Invalid argument

If bind_interface line is removed, it works OK

@nadav-bariks
Copy link

problem is with ipv6
strace shows

bind(5, {sa_family=AF_INET6, sin6_port=htons(8882), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fe80::9490:96c4:9f56:d81c", &sin6_addr), sin6_scope_id=0}, 28) = -1 EINVAL (Invalid argument)
write(2, "1669878630: Error: Invalid argum"..., 361669878630: Error: Invalid argument
)

adding
socket_domain ipv4
solves the problem

documentation does not say that bind_interface only works on ipv4

@jediminer543
Copy link

Ok, to add to this, the issue appears to occur because adapters always possess a link local address, and linux will return EINVAL when attempting to do this, unless you specify additional information to make link local addresses work

Mosquitto should probably either reject link-local addresses, or should properly handle them, by pulling more data out of the ifaddrs struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants