0

I'm customizing my minibian distro and now having hard time to set up two network interfaces: wireless (wlan0) and wired (eth0).

I want eth0 to have a static IP (in case I need to connect it to the network using wires), while wlan0 (set up with wpa_supplicant) to have a dhcp address from my wireless router.

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.254

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

/etc/wpa_supplicant/wpa_supplicant.conf:

# reading passphrase from stdin
network={
  ssid="my_wifi"
  #psk="Password"
  psk=03632d6ca0734abdb5ae1b889f8028552b196f6f7d40e365ebbef7d8d7ac7fee
}

The problem: when I connected to my router using cable over eth0, then both my interfaces (wlan0 and eth0) are connected to network - I can ping them both from my other machines.

If I unplug the eth0 in order to have only a wireless connection, then wlan0 also goes down and ping stops response stops.

But if I plug the cable back - I'm getting ping back on both interfaces (eth0 as well as wlan0)

What am I doing wrong?

EDIT:

So here is the interfaces details when the cable is connected:

root@raspberrypi:~# ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:a7:ba:c2
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fea7:bac2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1098 errors:0 dropped:0 overruns:0 frame:0
          TX packets:530 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:73489 (71.7 KiB)  TX bytes:57234 (55.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:f2:ef:97
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fef2:ef97/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1410 errors:0 dropped:35 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:140549 (137.2 KiB)  TX bytes:2792 (2.7 KiB

Ip command output:

root@raspberrypi:~# ip addr show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether b8:27:eb:a7:ba:c2 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::ba27:ebff:fea7:bac2/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:f2:ef:97 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.2/24 brd 192.168.1.255 scope global wlan0
           valid_lft forever preferred_lft forever
        inet6 fe80::ba27:ebff:fef2:ef97/64 scope link
           valid_lft forever preferred_lft forever

root@raspberrypi:~# ip route
default via 192.168.1.254 dev wlan0
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.100
192.168.1.0/24 dev wlan0  proto kernel  scope link  src 192.168.1.2
  • The gateway 192.168.1.254 is nonsense. It is unclear what networking system you are expecting to (or actually ) use. You have posted insufficient information to resolve. What is the output of ifconfig in both states. – Milliways Feb 6 '17 at 2:15
  • @Milliways added ifconfig output.. But I'm using ssh to connect and don't have monitor to use with rpi, so in a second state there is no connection and so can't give an output of ifconfig command... lol – Drew Feb 6 '17 at 2:41
  • @Milliway also removing gateway changed nothing(( – Drew Feb 6 '17 at 2:54
  • I did not say to remove it, just that it looked improbable. You have to determine the correct value. I still really don't understand WHY so many people want to use static addresses. If you removed all the static rubbish and let DHCP do its job it should work. You could then run ip route | grep default | awk '{print $3}' to determine the correct gateway. – Milliways Feb 6 '17 at 4:18
  • static address because it's gonna be a server – Drew Feb 6 '17 at 4:28

Your Answer

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

Browse other questions tagged or ask your own question.