0

As per the documentation found here I have setup my dhcpd.conf with the following:

interface eth0

static ip_address=192.168.4.102/24
static routers=192.168.4.1
static domain_name_servers=8.8.8.8

interface wlan0

static ip_address=192.168.4.102/24
static routers=192.168.4.1
static domain_name_servers=8.8.8.8

However after a reboot only the Wifi has the new static IP:

2: enxb827ebfa27e1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:fa:27:e1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.37/24 brd 192.168.4.255 scope global enxb827ebfa27e1
       valid_lft forever preferred_lft forever
    inet6 fe80::8dd2:e6ac:d404:fb53/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:af:72:b4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.102/24 brd 192.168.4.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::5837:7479:fa9d:288a/64 scope link
       valid_lft forever preferred_lft forever

I would have logically expected the Pi to:

  • Give both adaptors the same static IP address
  • Automatically switch between adaptors with a preference for Ethernet (and therefore only use one at a time)

How do I achieve this?

user9993
  • 109
  • 1
  • 2
  • The solution you can you find on [ Raspberry Pi Networking - Switching between wired and wireless networks in Raspbian & Debian ](http://www.aoakley.com/articles/2013-07-31-raspberry-pi-networking.php) The author uses static ips in his tutorial, but should work also with dynamic ips. Interesting is the ‘allow-hotplug’ command in the interface definition – CanadaRunner Oct 25 '20 at 16:16
  • Amazing that such a simple question is downvoted by neckbeards – user9993 Oct 26 '20 at 18:35

3 Answers3

1

As should be obvious from the listing you do NOT have eth0

It is difficult to say why you are using Predictable Network Interface Names (even though most distos use it) as the Foundation nobbled it (you do not say what OS you are using).

This is explained in How to set up networking/WiFi

No matter what you do you CAN NOT assign the same IP address to 2 interfaces

It is also difficult to understand what you mean by "Automatically switch between adaptors". You can assign different metrics to interfaces. route -n will show the current metrics.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Ah good point. Well, I selected yes when it asked, that's the reason I'm using it. By switch I would like it to use the ethernet when it's connected and switch to Wifi when it's not. I'm using raspbian. – user9993 May 12 '18 at 12:19
0

For the static part I know the answer (with a clean install) The new noops-Debian uses a different eth0=name it's in your case enxb827ebfa27e1 check this with

ifconfig 

Edit in /etc/dhcpcd (on top of the document)

profile static_eth0
interface enxb827ebfa27e1
static ip_address=192.168.4.102/24
static routers=192.168.4.1
static domain_name_servers=8.8.8.8 8.8.4.4

Edit in /etc/network/interfaces (chance the line with eth0 in:)

iface enxb827eb9e9b69 inet manual

then

reboot
RalfFriedl
  • 2,160
  • 2
  • 9
  • 11
0

What you want is called dynamic failover: switch over to another connection if one is broken but use a primary interface if both available. You can use bonding to achieve this but I haven't seen a solution with default network setup of Raspbian. With a little effort you can switch over to systemd-networkd to do this.

Look at Howto migrate from networking to systemd-networkd with dynamic failover.

Ingo
  • 40,606
  • 15
  • 76
  • 189