0

How would I be able to use my rPi with a fixed IP on the ethernet port and 'automatic' wifi?

I've got the credentials for the known accesspoints, with priority stored in /etc/wpa_supplicant/wpa_supplicant.conf

The RPi is autoconnecting to my wifi network, and I was able to SSH into the pi. Now, to setup the static IP for the ethernetport I followed this answer, and so:

In /etc/dhcpcd.conf I uncommented the following:

interface eth0
   static ip_address=x.y.z.5/24
   static routers=x.y.z.1
   static domain_name_servers=1.1.1.1

Then I ran

sudo systemctl disable dhcpcd
sudo systemctl enable networking

But now the pi doesn't connect to the Wifi anymore and I cannot connect to the ethernetport as this is a completely different subnet :)

So in the end I want to have the following:

  • Eth0 > static IP
  • Wlan0 > DHCP, with auto connect with credentials from wpa_supplicant.conf

The reason for this setup: I've got 5 public ip adresses with my provider; I want my pi to be on one of them. As the router itself is 'transparent' and managed by the provider I need to configure the ip settings, including gateway, for this interface manually. The wlan connection is just to configure the pi at my office (which is not the end location).

stUrb
  • 101
  • 1
  • 3

2 Answers2

2

Actually this command given in the Answer

sudo systemctl disable dhcpcd
sudo systemctl enable networking

is for Network Interfaces method not for dhcpcd method.

You just need to add these lines in dhcpcd.conf file or you can uncomment the default lines and edit them as per your IP address

interface eth0
static ip_address=192.168.1.1/24    
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

Once done save it using CTRL+O and then CTRL+X to exit. Then do sudo reboot or just this

sudo systemctl start dhcpcd.service
Amit Ray
  • 132
  • 1
  • 9
  • So if I do not specify the wlan interface in dhcpcd.conf it just defaults to auto conencting with dhcp? – stUrb Nov 05 '18 at 06:47
  • Using `CTRL+O` then only the cursor jumps and with `CTRL+X` nothing happens. – Ingo Nov 08 '18 at 10:32
  • its english alphabet O not zero. Also it is for nano editor. which editor you were trying to edit? – Amit Ray Nov 08 '18 at 13:57
1

You may have configured /etc/dhcpcd.conf but your next step sudo systemctl disable dhcpcd turns dhcpcd off so the configuration was futile.

It is unclear WHY you want to set Eth0 > static IP or why you are trying to set a gateway address for this interface.

There is no point being coy about x.y.z we don't know what you have done.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • 1
    *`domain_name_servers=1.1.1.1` cannot be correct!* why not? https://en.wikipedia.org/wiki/1.1.1.1 – Jaromanda X Nov 05 '18 at 00:19
  • I've got 5 public ip adresses with my provider; I want my pi to be on one of them. As the router itself is 'transparent' and managed by the provider i need to configure the ip settings, including gateway, for this interface manually. The wlan connection is just to configure the pi at my office, while the eth is configured for an other subnet – stUrb Nov 05 '18 at 06:46
  • The 1.1.1.1 is actually a real DNS server. The x.y.z is just a little obfuscating as the ip adresses are not in the private domain like 192.168.178.1 – stUrb Nov 05 '18 at 06:49
  • @stUrb I concede I did not know of this DNS, but the **real issue** is that **you did NOT follow** the linked tutorial; specifically **Then follow ONE of the following options.** NOTE you should edit additional detail into your question NOT Comments. – Milliways Nov 05 '18 at 06:53
  • @Milliways I now see you're the poster of that linked answer :) I did follow the answer; but I thought the two systemctl commands where for both options. – stUrb Nov 05 '18 at 09:00