0

This question is in relation with the following landmark article: How do I set up networking/WiFi/static IP address?

I have a raspberry PI3B+ with raspbian stretch lite (2018-10-09-raspbian-stretch-lite version) Predictable network interface names is disabled. My network card topology is as such:

  • eth0 connected via ethernet cable to a wrt54gl router with DHCP server on it.
  • wlan0 connected to my HUAWEI phone hotspot.
  • wlan1 is a TP-LINK TL-WN722N USB dongle which I need to configure with a static IP address for future setup as an access point.

Having tinkered with the /etc/network/interfaces for a while intending to configure my network as per most tutorials on the web, I came upon the article How do I set up networking/WiFi/static IP address? which basically explains how the way to configure network parameters is now different in Raspbian Stretch. I therefore updated my configuration files as such:

  • /etc/network/interfaces file is deleted

  • /etc/dhcpcd.conf file is appended with the following lines at the bottom:

    interface wlan1
    nohook wpa_supplicant
    static ip_address=192.168.3.1/24
    denyinterfaces wlan1
  • /etc/wpa_supplicant/wpa_supplicant.conf is as such:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=FR

    network=
    {
        ssid="HUAWEI"
        psk="xxxxxxx"
    }

After I boot:

  • eth0 connects correctly to the router it is hook up with and receives IP address through said router's DHCP server.
  • wlan0 connects correctly to the HUAWEI hotspot and receives an IP address through it.
  • wlan1 does not connect to HUAWEI (correctly applied the nohook argument). However it does not receive the 192.168.3.1 ip address as shown in the ifconfig screenshot bellow:
    wlan1: flags=4099  mtu 1500
            ether b8:27:eb:3b:f7:6f  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

I have tried to include a static IP for wlan1 in /etc/network/interfaces which doesnt work and takes every interface down.

I have also tried to add a post-up script in the same file to the same effect.

Question: Is there an actual way to configure a static IP from /etc/dhcpcd.conf or do I need to disable the DHCP client daemon and revert to using /etc/network/interfaces for my network setup (aka the old way)?

PS: I know I can manually set the IP after boot or script this, but would rather try to understand how to do it correctly via dhcpcd.

EDIT:

After enabling Predictable network interface names, and updating the dhcp.conf file accordingly I still cannot get a fixed IP from dhpcd for the USB wifi dongle. Bellow the updates and results for 2 different USB dongles.

With TP-LINK TL-WN722N

/etc/dhcpcd.conf

interface wlxc025e91f7d7f
static ip_address=192.168.3.1/24
nohook wpa_supplicant

After reboot

pi@raspberrypi:~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group 
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: enxb827eb6ea23a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc 
pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:6e:a2:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.2.112/24 brd 192.168.2.255 scope global enxb827eb6ea23a
   valid_lft forever preferred_lft forever
inet6 fe80::718c:2ecd:b4fb:5196/64 scope link 
   valid_lft forever preferred_lft forever
3: wlxc025e91f7d7f: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq 
state DOWN group default qlen 1000
link/ether c0:25:e9:1f:7d:7f brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state 
UP group default qlen 1000
link/ether b8:27:eb:3b:f7:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.43.245/24 brd 192.168.43.255 scope global wlan0
   valid_lft forever preferred_lft forever
inet6 fe80::9e31:7338:af4e:2b1/64 scope link 
   valid_lft forever preferred_lft forever

And there is only 1 line in the dhcp client log

pi@raspberrypi:~ $ journalctl -u dhcpcd | grep wlxc025e91f7d7f
Nov 27 08:33:52 raspberrypi dhcpcd[308]: wlxc025e91f7d7f: waiting for 
carrier

While with Alfa AWUS036NHA

/etc/dhcpcd.conf

interface wlx00c0ca979610
static ip_address=192.168.3.1/24
nohook wpa_supplicant

After reboot

pi@raspberrypi:~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group 
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: enxb827eb6ea23a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc 
pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:6e:a2:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.2.112/24 brd 192.168.2.255 scope global enxb827eb6ea23a
   valid_lft forever preferred_lft forever
inet6 fe80::718c:2ecd:b4fb:5196/64 scope link 
   valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state 
UP group default qlen 1000
link/ether b8:27:eb:3b:f7:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.43.245/24 brd 192.168.43.255 scope global wlan0
   valid_lft forever preferred_lft forever
inet6 fe80::9e31:7338:af4e:2b1/64 scope link 
   valid_lft forever preferred_lft forever
4: wlx00c0ca979610: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq 
state DOWN group default qlen 1000
link/ether 00:c0:ca:97:96:10 brd ff:ff:ff:ff:ff:ff

The DHCPCD service first probed the fixed IP address to the interface before removing it.

pi@raspberrypi:~ $ journalctl -u dhcpcd | grep wlx00c0ca979610
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: waiting for 
carrier
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: carrier acquired
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: IAID ca:97:96:10
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: adding address 
fe80::82f3:e742:c3cd:1379
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: probing address 
192.168.3.1/24
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: carrier lost
Nov 27 08:42:53 raspberrypi dhcpcd[335]: wlx00c0ca979610: deleting address 
fe80::82f3:e742:c3cd:1379

FYI with the /etc/dhcpcd.conf file left totally empty, both USB dongle connect fine to any wifi specified in the /etc/wpa_supplicant/wpa_supplicant.conf file.

  • First thing I notice is that wlan1 is not the TPLink, but the Pi's internal wifi (see mac address). You may have to use udev rules to 'fix' the physical device to interface name. – Dirk Nov 22 '18 at 22:11
  • You may also need to set 'per device' wpa_supplicant.conf file (IIRC thats wpa_supplicant-wlan0 for wlan0, etc) – Dirk Nov 22 '18 at 22:16
  • 1
    And I don't think you can use denyinterfaces and at the same time set a static address for the same device in dhcpcd.conf – Dirk Nov 22 '18 at 22:18
0

Your fundamental problem is "Predictable network interface names is disabled".

This was introduced to prevent the random assignment of wlan0/1 to interfaces due to a race condition.

If you enable Predictable network interface names the inbuilt WiFi device will be wlan0

You can Use different wpa_supplicant files as described in the tutorial.

If you want dhcpcd to manage the interface you do not need denyinterfaces wlan1

EDIT

You now seem to have resolved your problem; both the onboard WiFi and Ethernet seem to be configured.

However, you have NOT told the OS what you want to do with the other interface, so you cannot assign an address to the null protocol.

  • @F.Trechot DO NOT put detail in Comments. Update your question, including FULL output of ip a and current file settings. – Milliways Nov 27 '18 at 3:18

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.