0

/etc/Interfaces

auto lo

iface lo inet loopback
iface eth0 inet static

address 192.168.205.159
netmask 255.255.255.0
gateway 192.168.0.1

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

So i want to know if im doing something wrong as this interfaces configuration makes dhcpcd.service exit (most likely cause it configures a static ip but if thats the case why dosent it configure it correctly) doing hostname -I gives me an empty line, theres nothing in routes and ifconfig shows only lo running

UNOPARATOR
  • 153
  • 10
Meow
  • 29
  • 1
  • 5
  • Raspbian version? – M. Rostami Jan 30 '20 at 09:16
  • 1
    Is there any reason you ignored the warning in /etc/network/interfaces? **# Please note that this file is written to be used with dhcpcd

    For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'**

    If you really must use static IP do it properly see How to set up Static IP Address In addition the values you are attempting to use are inconsistent. There is little reason to set a static IP (particularly if you don't understand networking)

    – Milliways Jan 30 '20 at 10:00
  • Do you tried to set a static ip address in /etc/dhcpcd.conf on a fresh flashed Raspbian Buster installation? – Ingo Mar 03 '20 at 21:14

1 Answers1

1

The network manager of Buster is working (by default) with /etc/dhcpcd.conf. Therefore, change the configuration that file as you want.

sudo nano /etc/dhcpcd.conf  

Change these lines as you want:

# static IP configuration:
interface eth0
static ip_address=192.168.205.159/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.205.1
static domain_name_servers=192.168.1.251 

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0  

Then, recover the /etc/network/interfaces by adding these lines:

# 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

Also, you have configured the /etc/network/interfaces in the wrong way. If you're going to set the IP address on 192.168.205.159 with 255.255.255.0 subnet, you can't set a gateway with 192.168.0.1 address if you are using a simple local network. The gateway should be something 192.168.205.x.

M. Rostami
  • 4,323
  • 1
  • 17
  • 36
  • @Meow Have you restart network service or rebooted the rpi? – M. Rostami Jan 30 '20 at 09:40
  • @Meow The same situation with cat /etc/hostname? – M. Rostami Jan 30 '20 at 09:45
  • @Meow Also, you should recover the /etc/network/interfaces and add interface eth0 manual there. || Answer updated. – M. Rostami Jan 30 '20 at 09:51
  • 1
    @M.Rostami the etc/network/interfaces you listed is obsolete - I suggest you look at an unmodified Buster installation. – Milliways Jan 30 '20 at 10:05
  • @Milliways I've edited that part. As you know, in this case, iface eth0 inet manual should be added. Thanks for the notice. – M. Rostami Jan 30 '20 at 12:39
  • Deleted all the useless comments, but im still having a problem with not seeing any ip come up in hostname -I (i have a question can i set this up to work with any router in a network cause from what i see i need the ip of the router) – Meow Jan 30 '20 at 12:57
  • @Meow Please add the output of this command: cat /etc/hosts. It should have something like: 127.0.1.1 raspberrypi – M. Rostami Jan 30 '20 at 13:06
  • @Meow If you are looking for a command to gives you the exact IP address of the eth0 for using on bash, etc, you can fire this command: ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' – M. Rostami Jan 30 '20 at 13:10
  • @M.Rostami "As you know, in this case, iface eth0 inet manual should be added" I know no such thing. See How to set up networking/WiFi for Stretch/Buster defaults - in fact these effectively do NOTHING, and the file can just be deleted. All "manual" means is that the interface is configured by some other process. – Milliways Jan 31 '20 at 00:56
  • @Milliways I have read something on a SE answer here that talked about it. By the way, thank you for your clarification. – M. Rostami Jan 31 '20 at 00:59