3

in etc/network/interfaces:

iface eth0 inet static
  address 192.168.1.248
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

allow-hotplug wlan0
auto wlan0

iface wlan0 inet static
  address 192.168.1.248
  netmask 255.255.255.0
  network 192.168.1.0
  gateway 192.168.1.1
  dns-nameservers 192.168.1.1 # the router's IP
  wpa-ssid "my network name"
  wpa-psk "my password"
  • Sure, why not if you do the routing right. I'm not in a position to writeup a whole answer, but in the educational spirit of the Pi: have a look at how IP and ARP work. The OSI model will help you keep your sense of direction on your journey... The pot of gold at the end of the rainbow is a routing table in your router(s) with a higher cost on the Wifi route then on the wired one. – Chris Wesseling Mar 19 '14 at 8:00
6

Technically, you can. However you will have to hack the route table to make sure that every packet knows exactly where it should go to. Take this as an example (from a screwed up Ubuntu VM I used to operate, as this is a generic Linux problem):

  • eth0: 10.22.16.1/20, leads to machine 10.22.20.24.
  • eth1: 10.22.16.1/16, leads to router 10.22.0.1 that goes to the Internet

You need to set up the routing table so that packets to 10.22.20.24 goes through eth0 and everything else go to eth1, like:

ip route add 10.22.20.24 dev eth0
ip route add default via 10.22.0.1 dev eth1

Also, packet routing can be even more troublesome.

  • "packet routing can be even more troublesome"? – SDsolar Apr 23 '17 at 5:02
4

As other folks have said, not at "the same time". However, this doesn't mean they can't be configured simultaneously. When you plug in the Ethernet cable, you'd need to unplug the Wi-Fi, and if the Wi-Fi is plugged in you'd need to unplug the Ethernet. Keep in mind that switching would probably break current connections, so don't do it in the middle of a download.

1

Not at the same router at the same time. External machines don't know its the same machine. Every interfacecard is a unique address and a unique machine in the eyes of others.

If you choose not to be online with both interfaces at the same time, it will work as you tried with the static addresses in /etc/network/interfaces

Or, using DHCP, you could clone the macaddress from one interface to another, that way the DHCPserver would provide the same address.

Add the output of this line to the wlan0 section in /etc/network/interfaces:
ifconfig eth0 |grep -o -E "HWaddr\ [a-f0-9:]*"|sed s/HWaddr\ /hwaddr\ ether\ /

(Should look something like this: hwaddress ether 02:01:02:03:04:08)

  • 1
    Hmmm, i think your router wil have a harder time with cloned MAC addresses than with the same ip address. IP and its routing is designed to have multiple routes to the same destination address. (It was kind of the goal of the whole exercise) But MACs MUST be unique in your network. Only clone them if you really know what you are doing. – Chris Wesseling Mar 19 '14 at 7:51
  • that's true. I'm used to dhcp but if you assign static ipaddresses yourself is more likely to be useful. But then the advice stands: Not at the same time – ExploWare Mar 19 '14 at 11:16
  • Why not? Cloning a MAC address is a bad idea, unless you have a device that doesn't have one, or you want to impersonate another device (like the router your ISP lend you, when they've locked their service to their device). MAC must be unique. IP doesn't have to.. The whole point of routing tables is that there are "more roads that lead to rome". Having the same IP for different hosts that may become a challenge. – Chris Wesseling Mar 19 '14 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.