0

I have a Rasp-Pi 4B and it works OK using DHCP for both eth0 and wlan0. Wanting to install a LAMP system, I attempted to set up a static IP for the wi-fi. At address 100
Now.. I have managed to get my eth0 working again, but wi-fi will not connect, at least as a static. So far, I have not tried to back it out to DHCP again.
Following are some of my setup files:
ifconfig:

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.200.62  netmask 255.255.255.0  broadcast 192.168.200.255
        inet6 fe80::dea6:32ff:fe36:b41e  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:36:b4:1e  txqueuelen 1000  (Ethernet)
        RX packets 1002  bytes 245978 (240.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 684  bytes 106416 (103.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 312 (312.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 312 (312.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.200.100  netmask 255.255.255.0  broadcast 192.168.200.255
        ether dc:a6:32:36:b4:1f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

===== if route ====

    192.168.200.0/24 dev eth0 proto kernel scope link src 192.168.200.62 
    192.168.200.0/24 dev wlan0 proto kernel scope link src 192.168.200.100 linkdown

Note the linkdown. This there even after a
systemctl restart networking.service or a reboot.
Yes,I have issued a sudo ip route del 192.168.200.0/24 dev wlan0 to no effect. After reboot, the route is once again as above.
--------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'

# Include files from /etc/network/interfaces.d:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
allow hotplug eth0

auto wlan0
iface wlan0 inet static 
address 192.168.200.100
netmask 255.255.255.0

network 192.168.200.0
broadcast 192.168.200.255
gateway 192.168.200.1
dns-nameservers 192.168.200.98 1.1.1.1

source-directory /etc/network/interfaces.d 

(Note that interfaces.d is empty.)
---------dhcpcd.conf----------

### NOT YET! static ip_address=192.168.200.101
#
###interface wlan0
###static ip_address=192.168.200.100
####static routers=192.168.200.1
#####static domain_name_servers=1.1.1.1 8.8.8.8

As I said, I'd like to make the wlan0 have a staic address of ...200.100 but it remains dead (unless I revert it to DHCP).
More info required? Can provide!
Thanx!

aqk
  • 79
  • 1
  • 9
  • Does this answer your question? [How do I set up networking/WiFi/static IP address?](https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address) – Milliways Jan 20 '20 at 05:06
  • no. interface eth0 is on a different subnet. And appears superfluous. – aqk Jan 22 '20 at 05:55
  • I doubt that the information about setting up is not there. It is simple to setup interfaces on different subnets, but you did not ask about this. – Milliways Jan 22 '20 at 06:30

2 Answers2

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

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • I previously HAD the wlan0 static parameters in dhcpcd.conf, and after a myriad of suggestions across the internet, somewhere, someone said "put the static settings in ...network/interfaces" and don't use the dhcpcd file. So I commented them out in the latter. I'll try removing the wlan0 static lines in interfaces and rectivate them in dhcpcd.conf again. – aqk Jan 21 '20 at 02:50
  • @aqk across the internet you can find someone who said anything - most of it wrong. The rest of us choose to follow the Foundation recommendations for their official OS. – Milliways Jan 21 '20 at 02:59
0

Problem SOLVED! At least with the static Wi-Fi. After swapping a myriad of parameters, I finally completely deleted the /etc/network/interfaces, instead relying ONLY on the dhcpcd.conf.
The latter's layout is now

interface wlan0
static ip_address=192.168.200.100/24
static routers=192.168.200.1
static domain_name_servers=192.168.200.98 1.1.1.1 8.8.8.8

Note that there is NO reference to eth0 anywhere in it. (the 200.98 DNS is my old Pi-2 running Pihole)
Following is an ifconfig.

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether dc:a6:32:36:b4:1e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 60  bytes 3800 (3.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 60  bytes 3800 (3.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.200.100  netmask 255.255.255.0  broadcast 192.168.200.255
        inet6 fe80::dea6:32ff:fe36:b41f  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:36:b4:1f  txqueuelen 1000  (Ethernet)
        RX packets 9020  bytes 3718404 (3.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13084  bytes 3263711 (3.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

However, once a cat5 wire (same subnet) is plugged in, the network connection to the router automatically switches from Wi-fi to Ethernet! With the SAME 200.100 static address. And the wifi icon in bottom-rhs of the HDMI console changes to a madly flashing "up-down" Ethernet icon.
And note- there is no reference to eth0 in the dhcpcd.conf.
For folks interested, here is what the ifconfig looks like then-

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.200.100  netmask 255.255.255.0  broadcast 192.168.200.255
            inet6 fe80::dea6:32ff:fe36:b41e  prefixlen 64  scopeid 0x20<link>
            ether dc:a6:32:36:b4:1e  txqueuelen 1000  (Ethernet)
            RX packets 2317  bytes 774159 (756.0 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 3806  bytes 765316 (747.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 102  bytes 6420 (6.2 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 102  bytes 6420 (6.2 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.200.100  netmask 255.255.255.0  broadcast 192.168.200.255
            inet6 fe80::dea6:32ff:fe36:b41f  prefixlen 64  scopeid 0x20<link>
            ether dc:a6:32:36:b4:1f  txqueuelen 1000  (Ethernet)
            RX packets 23870  bytes 8040628 (7.6 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 33655  bytes 7977780 (7.6 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

If the Ethernet wire is subsequently disconnected, unfortunately both network connections are lost, until a
sudo systemctl restart dhcpcd.service is issued. From the HDMI console obviously, so don't try this if running headless!
Sometimes simplest is best. I struggled incredibly for a few days before arriving at the above, even at one point accidentally referring to "lo" as "io" - Another good reason to use sans-serif fonts in your terminal sessions!

aqk
  • 79
  • 1
  • 9
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Jan 23 '20 at 19:51