LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Switching from DHCP kills wifi (https://www.linuxquestions.org/questions/linux-newbie-8/switching-from-dhcp-kills-wifi-4175705656/)

bayou self 01-01-2022 06:29 AM

Switching from DHCP kills wifi
 
Happy New Year!
Debian 11 bullseye
Attempting to configure /etc/network/interfaces with static ip address.
Results in "No valid active connections found!"
Code:

me@debian:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlp2s0
iface wlp2s0 inet static
address 192.168.5.2
netmask 255.255.252.0
gateway 192.168.4.1
dns-nameservers 209.16.64.2 209.16.64.1

Code:

me@debian:~$ 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: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether f4:8e:38:94:e2:6a brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b0:c0:90:ac:cc:f1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.2/22 brd 192.168.7.255 scope global dynamic noprefixroute wlp2s0
      valid_lft 13422sec preferred_lft 13422sec
    inet6 fde5:7198:cd28:1:6abe:9fa0:ffca:57a/64 scope global temporary dynamic
      valid_lft 603725sec preferred_lft 84868sec
    inet6 fde5:7198:cd28:1:b2c0:90ff:feac:ccf1/64 scope global dynamic mngtmpaddr noprefixroute
      valid_lft 2591769sec preferred_lft 604569sec
    inet6 fe80::b2c0:90ff:feac:ccf1/64 scope link noprefixroute
      valid_lft forever preferred_lft forever


teckk 01-01-2022 08:05 AM

You gave very little info.

Code:

address 192.168.5.2
netmask 255.255.252.0

Code:

nmap -sL 192.168.5.2/22
Nmap scan report for 192.168.4.0
...
Nmap scan report for 192.168.7.255
Nmap done: 1024 IP addresses (0 hosts up) scanned in 0.02 second

So that will reach the gateway.

Code:

dns-nameservers 209.16.64.2 209.16.64.1
Code:

dig @209.16.64.2 google.com

; <<>> DiG 9.16.23 <<>> @209.16.64.2 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 6843
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: b088e45f09aa69adeea4ee0561d05e96dc1c99a817beb8ef (good)
;; QUESTION SECTION:
;google.com.                    IN      A

;; Query time: 30 msec
;; SERVER: 209.16.64.2#53(209.16.64.2)
;; WHEN: Sat Jan 01 08:03:50 CST 2022
;; MSG SIZE  rcvd: 67

dig @8.8.8.8 google.com

; <<>> DiG 9.16.23 <<>> @8.8.8.8 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21474
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.            300    IN      A      142.250.191.206

;; Query time: 26 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sat Jan 01 08:03:11 CST 2022
;; MSG SIZE  rcvd: 55

Have you tried another DNS.

Can you ping by IP, and not URL?

Need more info.

Quote:

wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether b0:c0:90:ac:cc:f1 brd ff:ff:ff:ff:ff:ff
inet 192.168.5.2/22 brd 192.168.7.255 scope global dynamic noprefixroute wlp

bayou self 01-01-2022 09:36 AM

Thanks for your help!
I will be more than happy to provide more info (assuming I understand what is required).
I have wifi connectivity now, because I erased this
Code:

auto wlp2s0
iface wlp2s0 inet static
address 192.168.5.2
netmask 255.255.252.0
gateway 192.168.4.1
dns-nameservers 209.16.64.2 209.16.64.1

returning the interfaces file to its original form.
Code:

me@debian:~$ sudo nmap -sL 192.168.5.2
Starting Nmap 7.80 ( https://nmap.org ) at 2022-01-01 09:21 CST
Nmap scan report for 192.168.5.2
Nmap done: 1 IP address (0 hosts up) scanned in 0.01 seconds

Do you need the results of the dig command?

computersavvy 01-01-2022 10:01 AM

Would you please provide the output of ' ip address show ' and ' ip route show '

I suspect a subnet issue with different netmasks between the router and your host.

michaelk 01-01-2022 10:05 AM

By default debian uses network manager which basically connects to the router/access point then runs dhclient to acquire an IP address

Network manager does have the capability to configure a static IP address.

If you want to setup wireless manually you will need to disable network manager and also add the router's SSID and passphrase.

https://wiki.debian.org/WiFi/HowToUse

bayou self 01-01-2022 10:25 AM

@computersavvy
Code:

me@debian:~$ ip address show
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: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether f4:8e:38:94:e2:6a brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b0:c0:90:ac:cc:f1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.3/22 brd 192.168.7.255 scope global dynamic noprefixroute wlp2s0
      valid_lft 13977sec preferred_lft 13977sec
    inet6 fde5:7198:cd28:1:170a:680b:8806:5346/64 scope global temporary dynamic
      valid_lft 604376sec preferred_lft 85519sec
    inet6 fde5:7198:cd28:1:b2c0:90ff:feac:ccf1/64 scope global dynamic mngtmpaddr noprefixroute
      valid_lft 2591997sec preferred_lft 604797sec
    inet6 fe80::b2c0:90ff:feac:ccf1/64 scope link noprefixroute
      valid_lft forever preferred_lft forever

Code:

me@debian:~$ ip route show
default via 192.168.4.1 dev wlp2s0 proto dhcp metric 600
192.168.4.0/22 dev wlp2s0 proto kernel scope link src 192.168.5.3 metric 600


uteck 01-01-2022 11:26 AM

Manually configuring network settings for wireless needs more configuration then wired. This link has a condensed write-up about it: https://linuxconfig.org/how-to-conne...bian-10-buster

computersavvy 01-01-2022 01:20 PM

The info provided from your host looks good. Was that when you had manually set the static address or dhcp?
What is the subnet mask on the router?
If the router netmask and the host netmask differ then it causes problems. If they are the same, then the network address should be 192.168.4.0/22 which gives you the usable subnet addresses 192.168.4.1 - 192.168.7.254 with broadcast at 192.168.7.255. That is indicated on the host info you posted, but needs to be verified to match on the router.

bayou self 01-01-2022 01:47 PM

Quote:

The info provided from your host looks good. Was that when you had manually set the static address or dhcp?
The code from post #6 is from my machine in stock form, without my code from post #3. I have not successfully set or changed anything (yet!).

Quote:

What is the subnet mask on the router?
I don't know how to find this.
Code:

me@debian:~$ sudo route -n
[sudo] password for me:
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
0.0.0.0        192.168.4.1    0.0.0.0        UG    600    0        0 wlp2s0
192.168.4.0    0.0.0.0        255.255.252.0  U    600    0        0 wlp2s0




Quote:

...then the network address should be 192.168.4.0/22
Would that be my machine's ip address or the gateway?

bayou self 01-01-2022 05:02 PM

I tried nm-connection-editor, and I'm cautiously optimistic, as it is working for now. I entered the same data for address, netmask, gateway, and nameservers as in post #3 above.
/etc/NetworkManager/system-connections has same. /etc/network/interfaces is unmodified.

michaelk 01-01-2022 05:08 PM

The only caveat is the static IP address should not be in the range of addresses assigned by the DHCP server otherwise there could be a conflict.

bayou self 01-01-2022 05:31 PM

@michaelk,
The IP address I chose was from one of the many found when running "ip a"...you are saying that's not good?

Q1: Is DHCP still active?
Q2: How do I find the range of addresses assigned by the DHCP server?
Q3: Can I assign the IP address any way I want, such as 192.168.anything.anything?

TB0ne 01-01-2022 05:38 PM

Quote:

Originally Posted by bayou self (Post 6314027)
@michaelk,
The IP address I chose was from one of the many found when running "ip a"...you are saying that's not good?

Q1: Is DHCP still active?
Q2: How do I find the range of addresses assigned by the DHCP server?
Q3: Can I assign the IP address any way I want, such as 192.168.anything.anything?

I'd ask why you're wanting/needing to do this. If this is a laptop, you're just going to make it more difficult for yourself to take it places and use it, since the address you set for your home, most likely won't work in another location. Having a 'set' address for your system does make some things easier, though....I'd suggest going into your router settings, and set your device to 'keep' the DHCP address. It should tie to the MAC address on the system, and every time it comes up at home it'll get the same address. But in another location, it'll work normally.

michaelk 01-01-2022 05:55 PM

Quote:

The IP address I chose was from one of the many found when running "ip a"...you are saying that's not good?
The IP address found from the IP command was assigned by a DHCP server, either by your router, ISP or however you connect to the internet. If it isn't your own router then as soon as the DHCP lease expires that address goes back into the pool and could be assigned to other computers on the same network. If that happens there could be an address conflict which means that you and the other computer will not be able to access the network/internet.

Q1: The server is still active but your computer will not ask it for an address. Most DHCP servers now days will try to assign the same address to the same computer as long as the lease is still active.

Q2: If you do not own or have access to the router or device that runs DHCP server then it is not possible. If you do own the router then you can login to its web configuration page to check the range. If the latter is true then you might want to configure an address reservation versus static IP address which is essentially the same thing. This would be better if your PC is a laptop.

Q3: It depends. If the network/router is your own then basically yes but it must be within the same subnet as assigned by your router but again outside its DHCP server range. Otherwise no.

bayou self 01-01-2022 06:28 PM

@TB0ne
Quote:

I'd ask why you're wanting/needing to do this.
Linux From Scratch
Quote:

If this is a laptop, you're just going to make it more difficult for yourself
Stationary desktop

From Linux From Scratch Version 11.0, Chapter 9--General Network Configuration
Quote:

The following command creates a sample file for the eth0 device with a static IP address:

cd /etc/sysconfig/
cat > ifconfig.eth0 << "EOF"
ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
EOF

The values in italics must be changed in every file to match the proper setup.


All times are GMT -5. The time now is 08:08 PM.