5

I have followed many tutorials and when I get to the point

sudo nano /etc/network/interfaces

Remove the line that reads iface eth0 inet dhcp

I do not get the above line, the only similar line is

iface eth0 inet manual

I end up just going along and deleting and replacing the above line but when I try to ping gateways IP address it fails.... any suggestions?

guntbert
  • 115
  • 5
Don Whittington
  • 51
  • 1
  • 1
  • 3
  • @goldilocks Not really a duplicate, as the other was posted later, admittedly partly inspired by this question. – Milliways Nov 05 '15 at 08:44
  • Duplicates don't have lead into the past. Ideally, the closed questions work as sign posts leading to a canonical answer, potentially in chains, and these can be rearranged (although it takes either a mod hammer, or a sufficiently large group of users working in concert via chat to do so; unfortunately the "one size fits all" system makes the latter unlikely to happen here). – goldilocks Nov 05 '15 at 08:58

1 Answers1

7

All of these "tutorials" are obsolete. (Note they can still be used if you want to use the older style of manual configuration, but this requires detailed knowledge.)

If you are running a recent Raspbian /etc/network/interfaces should be as below. If you have changed it PUT IT BACK.

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

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

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

Edit /etc/dhcpcd.conf as follows (extract from man dhcpcd.conf):-

 Configures a static value.  If you set ip_address then dhcpcd will not attempt to obtain a lease
 and just use the value for the address with an infinite lease time.

 Here is an example which configures a static address, routes and dns.
       interface eth0
       static ip_address=192.168.0.10/24
       static routers=192.168.0.1
       static domain_name_servers=192.168.0.1

PS I still think setting up a static address is almost always the wrong thing to do. If possible set a static reservation in your router (if possible) or use a zero-conf such as avahi

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Well the reason I want my pi's to have a static ip is because I am trying to get them to communicate to each other. I kept hitting hiccups and thought that it might be because the ip address was changing. I appreciate the advice and I will try it out – Don Whittington Nov 05 '15 at 13:34
  • Can I still use cmdline.txt? – Rendicahya Feb 27 '16 at 02:15
  • re your last paragraph: you may be right - except when that pi **is** the DHCP server. – guntbert Feb 11 '21 at 18:34