Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Same IP, multiple interfaces using dhcpcd, systemd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mieses
Tux's lil' helper
Tux's lil' helper


Joined: 28 Feb 2004
Posts: 110

PostPosted: Wed Oct 08, 2014 10:50 pm    Post subject: Same IP, multiple interfaces using dhcpcd, systemd Reply with quote

Is it possible to configure dhcpcd to accept the same IP address on multiple interfaces? For example, consider a laptop where only one interface is enabled at a time with the wired interface having priority over the wireless interface. An OpenWRT router is running dnsmasq and is configured to assign the same IP address to all MAC addresses belonging to this laptop.

OS X, Ubuntu and Windows are able assign the same IP address to multiple interfaces and seem to do this by default. What is the intended behavior in Gentoo for this case when running dhcpcd, NetworkManager, and systemd?

When the Wi-Fi interface comes up on Gentoo, dnsmasq tries to assign the same IP and dhcpcd rejects the lease noting that the wired interface on the same laptop has already claimed it. journalctl reports the following:
Code:
Oct 08 14:55:48 testgentoo dhcpcd[14263]: version 6.4.7 starting
Oct 08 14:55:48 testgentoo NetworkManager[14137]: <info> (wlp3s0): DHCPv4 state changed nbi -> preinit
...
Oct 08 14:55:48 testgentoo dhcpcd[14263]: wlp3s0: soliciting a DHCP lease
Oct 08 14:55:48 testgentoo dhcpcd[14263]: wlp3s0: offered 192.168.0.235 from 192.168.0.10
Oct 08 14:55:48 testgentoo dhcpcd[14263]: wlp3s0: hardware address c8:2a:14:29:b9:2d claims 192.168.0.235
Oct 08 14:55:51 testgentoo dhcpcd[14263]: wlp3s0: soliciting a DHCP lease
Oct 08 14:55:53 testgentoo dhcpcd[14263]: wlp3s0: offered 192.168.0.106 from 192.168.0.10
Oct 08 14:55:58 testgentoo dhcpcd[14263]: wlp3s0: leased 192.168.0.106 for 43200 seconds
Oct 08 14:55:58 testgentoo dhcpcd[14263]: wlp3s0: adding route to 192.168.0.0/24


If dhcpcd would allow the same IP (192.168.0.235) to be assigned to both interfaces simultaneously, then dnsmasq would be able to assign the same name to both the wired and wireless interfaces of the same machine.

For comparison, here are the router logs when the Wi-Fi interface is disabled and enabled on this Gentoo machine and OS X.

router log events upon disabling WiFi interface in OS X client.
Code:
Oct  8 22:12:06 router daemon.info hostapd: wlan1: STA 8c:2d:aa:31:ac:99 IEEE 802.11: disassociated
Oct  8 22:12:07 router daemon.info hostapd: wlan1: STA 8c:2d:aa:31:ac:99 IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)


router log events upon enabling WiFi interface in OS X client.
Code:
Oct  8 22:20:37 router daemon.info hostapd: wlan1: STA 8c:2d:aa:31:ac:99 IEEE 802.11: authenticated
Oct  8 22:20:37 router daemon.info hostapd: wlan1: STA 8c:2d:aa:31:ac:99 IEEE 802.11: associated (aid 1)
Oct  8 22:20:37 router daemon.info hostapd: wlan1: STA 8c:2d:aa:31:ac:99 WPA: pairwise key handshake completed (RSN)
Oct  8 22:20:38 router daemon.info dnsmasq-dhcp[26283]: DHCPREQUEST(br-lan) 192.168.0.14 8c:2d:aa:31:ac:99
Oct  8 22:20:38 router daemon.info dnsmasq-dhcp[26283]: abandoning lease to a8:20:66:51:ff:45 of 192.168.0.14
Oct  8 22:20:38 router daemon.info dnsmasq-dhcp[26283]: DHCPACK(br-lan) 192.168.0.14 8c:2d:aa:31:ac:99 testmac


router log events upon enabling WiFi interface in Gentoo client.
Code:
Oct  8 22:14:33 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a IEEE 802.11: authenticated
Oct  8 22:14:33 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a IEEE 802.11: associated (aid 1)
Oct  8 22:14:33 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a WPA: pairwise key handshake completed (RSN)
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPREQUEST(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPNAK(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a static lease available
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPDISCOVER(br-lan) e4:ce:8f:56:1c:2a
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPOFFER(br-lan) 192.168.0.235 e4:ce:8f:56:1c:2a
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPREQUEST(br-lan) 192.168.0.235 e4:ce:8f:56:1c:2a
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPACK(br-lan) 192.168.0.235 e4:ce:8f:56:1c:2a testgentoo
Oct  8 22:14:34 router daemon.info dnsmasq-dhcp[26283]: DHCPDECLINE(br-lan) 192.168.0.235 e4:ce:8f:56:1c:2a Duplicate address detected
Oct  8 22:14:34 router daemon.warn dnsmasq-dhcp[26283]: disabling DHCP static address 192.168.0.235 for 10m
Oct  8 22:14:37 router daemon.warn dnsmasq-dhcp[26283]: not using configured address 192.168.0.235 because it was previously declined
Oct  8 22:14:40 router daemon.info dnsmasq-dhcp[26283]: DHCPDISCOVER(br-lan) e4:ce:8f:56:1c:2a
Oct  8 22:14:40 router daemon.info dnsmasq-dhcp[26283]: DHCPOFFER(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a
Oct  8 22:14:40 router daemon.info dnsmasq-dhcp[26283]: DHCPREQUEST(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a
Oct  8 22:14:40 router daemon.info dnsmasq-dhcp[26283]: DHCPACK(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a testgentoo


router log events upon disabling WiFi interface in Gentoo client.
Code:
(no events reported)


3 minutes later, router log events upon enabling WiFi interface in Gentoo client.
Code:
Oct  8 22:17:47 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a IEEE 802.11: authenticated
Oct  8 22:17:47 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a IEEE 802.11: associated (aid 1)
Oct  8 22:17:47 router daemon.info hostapd: wlan1: STA e4:ce:8f:56:1c:2a WPA: pairwise key handshake completed (RSN)
Oct  8 22:17:48 router daemon.info dnsmasq-dhcp[26283]: DHCPREQUEST(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a
Oct  8 22:17:48 router daemon.info dnsmasq-dhcp[26283]: DHCPACK(br-lan) 192.168.0.106 e4:ce:8f:56:1c:2a testgentoo
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Oct 09, 2014 12:01 am    Post subject: Reply with quote

Heh, you're like the 2nd person to ask for this in about 5 years!

It is on my personal radar to address, but please do file a ticket:
http://roy.marples.name/projects/dhcpcd

Login as anonymous and enter password as the ascii banner and create the ticket please!
It's actually not a small job ....
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
mieses
Tux's lil' helper
Tux's lil' helper


Joined: 28 Feb 2004
Posts: 110

PostPosted: Thu Oct 09, 2014 6:18 am    Post subject: Reply with quote

Thank you. It's good to know that it's working as intended. I will post an issue on your tracker.

Out of pure curiosity, how would the solution work? How is the wireless interface de-prioritized when the wired interface is plugged in and receives the same IP as the wireless interface? Do both interfaces stay up and one is configured to route through the other?
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Oct 09, 2014 9:10 am    Post subject: Reply with quote

Oh that's easy. Here is the code

Code:
      ifp->metric = 200 + ifp->index;
      if (if_getssid(ifp) != -1) {
         ifp->wireless = 1;
         ifp->metric += 100;
      }


Index is a low number assigned by the kernel to each interface

This is also user editable in dhcpcd.conf

Code:
interface eth0
metric 111


Lowest metric is preferred.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Oct 09, 2014 9:21 am    Post subject: Reply with quote

Internally, dhcpcd would remove the conflicting IP address from high metric interfaces and then assign it to low metric ones.
This does force ably break connections, but it already does this with routes, so IP addressing working the same way isn't much of a stretch.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Oct 09, 2014 7:00 pm    Post subject: Reply with quote

You didn't post a ticket :(

But I've already made the change here:
http://roy.marples.name/projects/dhcpcd/ci/77611ce41704345c8037a465ef0af8d7a129d7cd?sbs=0
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Oct 09, 2014 9:32 pm    Post subject: Reply with quote

Re-reading your post, it won't work for you because you're using network manager.
You'll need to disable ARP checking in dhcpcd.conf or tweak your kernel config as described here:
https://www.ibm.com/developerworks/community/blogs/tclaret/entry/linux_considers_an_ip_address_as_belonging_to_a_host_rather_than_an_interface?lang=en
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Tue May 05, 2015 8:19 am    Post subject: Reply with quote

Holy thread necro batman!

Anyway, just a heads up that dhcpcd-6.5.1 upwards do this.
If you have say wired and wireless and both are active then the wired interface will have the IP address.
When unplugged, the IP address will move to the wireless interface.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Tue May 05, 2015 12:30 pm    Post subject: Reply with quote

UberLord wrote:
If you have say wired and wireless and both are active then the wired interface will have the IP address.
When unplugged, the IP address will move to the wireless interface.

Lovely. :-)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum