2

I would like to set up my Raspberry Pi as static IP device, which communicates over Ethernet (through an IP like 192.168.20.X), and at the same time it should be connected to the internet through WLAN (192.168.1.1). However when I allow 'auto eth0' then it does not configure the wlan0. I would like both of them to work. My current configuration is given below:

source-directory /etc/network/interfaces.d
auto lo

iface lo inet loopback

auto eth0  
iface eth0 inet static
 address 192.168.20.40
 netmask 255.255.255.0
 network 192.168.20.1
 gateway 192.168.20.1


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

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

What am I missing? Any help would be appreciated. Thanks in advance.

SOLVED:

source-directory /etc/network/interfaces.d
auto lo

iface lo inet loopback

auto eth0  
iface eth0 inet static
 address 192.168.20.45
 netmask 255.255.255.0
 network 192.168.20.1
 gateway 192.168.1.1    # Changing this worked
 dns-nameservers 8.8.8.8 8.8.4.4

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

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
3

I have a similar configuration: static ip on eth0 and dynamic on wlan0.

This is the content of my /etc/network/interfaces file:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Where I configure the dhcp or static addresses is in /etc/dhcpcd.conf

interface eth0
static ip_address=192.168.20.40
static routers=192.168.20.1
nogateway

interface wlan0
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4

(I adapted the file to your configuration)

You also have to configure the Wifi (SSID, password, etc) in /etc/wpa_supplicant/wpa_supplicant.conf (as I supose you already did)

NOTE: I'm using raspbian jessie. I think in previous versions (wheezy) network configuration is done different

EDIT: Added configuration for DNS

  • This other question maybe can help: dhcpcd-vs-etc-network-interfaces – migrc Oct 28 '16 at 12:25
  • I'm using jessie and I'm afraid it cant find no wireless interfaces now. eth0: Link is down, wlan0:Not associated. Also, the wpa psk stuff is correctly configured as I connected to it before. I simply added interfaces below /etc/dhcpcd.conf. Maybe I need to edit some stuff there? – mozcelikors Oct 28 '16 at 13:02
0

SOLVED:

source-directory /etc/network/interfaces.d
auto lo

iface lo inet loopback

auto eth0  
iface eth0 inet static
 address 192.168.20.45
 netmask 255.255.255.0
 network 192.168.20.1
 gateway 192.168.1.1    # Changing this worked
 dns-nameservers 8.8.8.8 8.8.4.4

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

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  • It is the same answer proposed by @migrc , you should accept it as the best/working answer . – GAD3R Nov 4 '16 at 19:01
  • 1
    Not exactly @GAD3R. He set the configuration in /etc/network/interfaces while I suggested him to configure the connection using the file /etc/dhcpcd.conf (and he said it didn't work for him). Thanks anyway. – migrc Nov 10 '16 at 7:17

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.