How to purge all network related config? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

How to purge all network related config?

Post by Akrai »

I received the raspi 4 two days ago, i have had an odroid c1 running with dietpi since a year or two flawlessly. As the c1 doesn't have wifi and in my tv there is no ethernet connection, and since i wanted to have a reliable pihole system (the c1 when downloading torrents it gets pretty slow, and critical systems like the dns server of pihole must not suffer any lag or it will be noticeable for the users of the network) i decided to replace it with the raspi 4.

The thing is i have been trying to just have a very usual ethernet+wifi setting, what i want to have, ideally, is a system which stays plugged to ethernet normally, and that when i want to play videos in the tv i just turn it off, unplug it and take it to the tv, and it will connect to wifi, and while it is connected to ethernet, the wifi should not be connected (just as happens in any desktop computer), and lastly (ideally, harder to get, so its optional) i would want to have always the same ip (you know, if you use pihole you must set an ip in the dhcp so the rest of the devices can know where is the dns server, so if i have a different ip in ethernet and in wifi (NOTE: i know it is not possible to have the same ip in two interfaces at the SAME TIME, i know it, i dont want that, as i said my intention is to only be using one interface at the same time, the other one would be unplugged or just disconnected) the dns would not be reachable while im on the tv, for example)

the same ip thing is harder, i could set the same ip as a static ip internally in the raspi, and just pray that the router accepts it, which would probably require a reboot in the router when i want to change interface... but there is also an option which i just discovered, https://wiki.archlinux.org/index.php/Wireless_bonding

but nevermind, im just gonna forget about the same ip requirement and try to fix the other things, it just is very hard to set wifi, its very unreliable, im talking just even without exiting the setup of the first boot, maybe its because using a 5G network fucks up (sorry for the word) some settings, or maybe its that using ethernet and wifi is untested or i dont know but i have just reached a point of setting only 1 SSID and just avoiding at all costs plugging the raspi to ethernet because i know if i do the wifi will stop working. I have had to reflash the iso 3 times now as it gets a point where neither ethernet or wifi works at all, maybe if you try to set a static ip in the wifi it is not programmed properly or something.

This post is more for telling the devs there are problems setting basic network stuff in the dietpi config. But anyway, what i want to know is, if i reach again the point of neither ethernet or wifi works, at all, how do i purge all network related config so i can just reconfigure it?
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

Hi,

it is possible to use 2 different IP addresses on eth0 as well as wlan0 together with PiHole. You would need to configure your DHCP server that way, that it will populate both IP Address as Primary + Secondary DNS Server. Means, if DNS server is not answering on first IP, your devices will be using second one.

Basically all network related configuration can be done using dietpi-config. If needed you can hack it manually into /etc/network/interfaces
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

Joulinar wrote: Fri Jun 19, 2020 3:40 pm Hi,

it is possible to use 2 different IP addresses on eth0 as well as wlan0 together with PiHole. You would need to configure your DHCP server that way, that it will populate both IP Address as Primary + Secondary DNS Server. Means, if DNS server is not answering on first IP, your devices will be using second one.

Basically all network related configuration can be done using dietpi-config. If needed you can hack it manually into /etc/network/interfaces
yeah, i know, i have been using dietpi-config for that, i just plug the ethernet, and for wifi i just enable the wifi modules and the inboard wifi, then add ssid and so on, my issues are reported and acknowledged in github, michaing said that as he doesnt use wifi he didnt test that type of combination of interfaces
and i have experienced that when my pihole is down, the other computers doesnt have any access to internet, even when the second and third DNS directions are the google ones... i dont know why but thats what happened to me


but is there a way to purge or delete every network related config set by me from the install?

and the ssid and other wifi related config where is stored or edited manually?
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

I just tested it on my demo environment
  1. Pihole running + listen on all interfaces
  2. eth0 configured, set STATIC IP1
  3. wlan0 configured, set STATIC IP2
  4. DHCP set to populate IP1 + IP2 as DNS server (dnsmasq dhcp-option=6)
  5. DHCP lease refreshed on a client
  6. check that both IP's get populates as DNS server

    Code: Select all

    root@DietPiVM2:~# nmap --script broadcast-dhcp-discover -e eth0
    Starting Nmap 7.70 ( https://nmap.org ) at 2020-06-19 15:27 CEST
    Pre-scan script results:
    | broadcast-dhcp-discover:
    |   Response 1 of 1:
    |     IP Offered: 192.168.0.39
    |     DHCP Message Type: DHCPOFFER
    |     Server Identifier: 192.168.0.11
    |     IP Address Lease Time: 2m00s
    |     Renewal Time Value: 1m00s
    |     Rebinding Time Value: 1m45s
    |     Subnet Mask: 255.255.255.0
    |     Broadcast Address: 192.168.0.255
    |     Domain Name: lan
    |     NTP Servers: 192.168.0.1
    |     Router: 192.168.0.1
    |_    Domain Name Server: 192.168.0.12, 192.168.0.70
    WARNING: No targets were specified, so 0 hosts scanned.
    Nmap done: 0 IP addresses (0 hosts up) scanned in 3.81 seconds
    root@DietPiVM2:~#
  7. verify DNS server setting on client

    Code: Select all

    root@DietPiVM2:~# cat /etc/resolv.conf
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 192.168.0.12
    nameserver 192.168.0.70
    search lan
    root@DietPiVM2:~#
    
  8. running nslookup to verify DNS resolution > DNS on IP1 was providing the answer

    Code: Select all

    root@DietPiVM2:~# nslookup google.com
    Server:         192.168.0.12
    Address:        192.168.0.12#53
    
    Non-authoritative answer:
    Name:   google.com
    Address: 216.58.205.238
    Name:   google.com
    Address: 2a00:1450:4001:820::200e
    
    root@DietPiVM2:~#
    
  9. disable eth0 on PiHole system
  10. running nslookup to verify DNS resolution > DNS on IP2 was providing the answer

    Code: Select all

    root@DietPiVM2:~# nslookup google.com
    Server:         192.168.0.70
    Address:        192.168.0.70#53
    
    Non-authoritative answer:
    Name:   google.com
    Address: 216.58.205.238
    Name:   google.com
    Address: 2a00:1450:4001:820::200e
    
    root@DietPiVM2:~#
    

As already stated above, network config is stored on /etc/network/interfaces. There you have as well wifi configuration done. by default wpa configuration should pointing to /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

root@DietPi3:~# cat /etc/network/interfaces |grep wpa
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
root@DietPi3:~#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

hmm yeah i would have to test it more deeply, it happened to me once and as it wasnt at all my priority to have pihole working i just changed the dns in the dhcp to another public one to keep fixing the raspberry, my real issues are with connectivity
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

my real issues are with connectivity
What exactly does this mean?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

Joulinar wrote: Fri Jun 19, 2020 4:19 pm
my real issues are with connectivity
What exactly does this mean?
is what i talked about in the opening post
Akrai wrote: Fri Jun 19, 2020 10:01 am
but nevermind, im just gonna forget about the same ip requirement and try to fix the other things, it just is very hard to set wifi, its very unreliable, im talking just even without exiting the setup of the first boot, maybe its because using a 5G network fucks up (sorry for the word) some settings, or maybe its that using ethernet and wifi is untested or i dont know but i have just reached a point of setting only 1 SSID and just avoiding at all costs plugging the raspi to ethernet because i know if i do the wifi will stop working. I have had to reflash the iso 3 times now as it gets a point where neither ethernet or wifi works at all, maybe if you try to set a static ip in the wifi it is not programmed properly or something.
basically, even without leaving the first setup, i can't tell you exactly what combination of settings bugs my connectivity but having both ethernet and wifi in autoassigned ip can make both interfaces just not connecting at all or having the ethernet connected but internet not working.
I just ended by having only one ssid configured, with autoassigned in both interfaces, and it just works for now, but i have spent 2 days trying to know what the hell was happening as just using very common settings made the connection just not work, not connect at all or showing as connected but no internet connection happening
i suspect it has to do with the way the dietpi network config is designed, as michaing said in github the network of a raspberry is very usually connected only by ethernet, and that is what is more tested and is more easy to program, and the wifi or even more the wifi+ethernet is not as tested
also, maybe having tried to use a 5g wifi maybe have some bug that is the origin of all my issues, is the one ssid i just gave up to configure and now its only configured to connect to a 2.4ghz ssid, now it just works reliability, but im not gonna touch anything or connect it to ethernet as i dont want to spend more hours fixing those basic network problems
maybe you can reproduce this issues testing ethernet+wifi 5g in a raspi 4
i can also say that during the setup sometimes it worked both eth+wlan connection at the same time without problems but maybe after a reboot or after adding the other ssid or something it just stopped working everything or only wifi stopped working
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

I was playing around with the ifplugd package. After some config attempts, my system is now able to switch between eth0 and wlan0 depending on eth0 status. As soon as a cable is connected, WiFi get deactivated. Removing the cable will activate WiFi. Working as well on boot. This way, only 1 interface is up same time.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

Joulinar wrote: Sat Jun 20, 2020 3:39 am I was playing around with the ifplugd package. After some config attempts, my system is now able to switch between eth0 and wlan0 depending on eth0 status. As soon as a cable is connected, WiFi get deactivated. Removing the cable will activate WiFi. Working as well on boot. This way, only 1 interface is up same time.
okay i have been playing with ifplugd a little bit, i did this:
installed ifplugd, then using http://www.aoakley.com/articles/2013-07 ... orking.php i followed the Turning off WiFi when a wired network cable is plugged in, basically edited /etc/ifplugd/action.d/ifupdown and /etc/network/interfaces and the first file was just copypasted, and the second one i edited it with my ips, except i decided to not experiment using the same static ip in both interfaces for now
then i used wpa_cli to replace and have only 1 ssid (a 5G one, if that matters), and rebooted and now the thing is it looks like wpa_supplicant is not the program which is providing the ssid config to the system, because if i enter dietpi-config to monitor the status of the network connectivity, i can see that ethernet is connecting and disconnecting properly, with the ip i set in the interfaces file, but the wlan is not working as expected, it doesnt connect at all but it happens that if i connect ethernet it then connects to the wlan, at the same time (ignoring the ifplugd setting), also if i enter the wlan menu, the ssid is the old one i set yesterday (2.4g) not the one i just set, so i suppose dietpi is not using wpa supplicant, can you guide me from here? i wanna edit manually or at least monitor the config file where it is configured the ssids, and also fix the ifplugd behaviour

edit: if i boot unplugged, it just doesnt connect, it waits the 60 seconds of the ntp daemom, then it waits i think like 2 minutes of postboot script, and then i can log in, also in the welcome print of the terminal, which tells you the cpu temp and dietpi news and so on, it says LAN IP: and the static ip of my ethernet, which has not been plugged in at all during the whole process
Now after all this time and after the time i have been writing all of this, the wlan still has not connected, i can see it in the dietpi config, also if i plug the ethernet right now, i see ethernet connected but still wlan doesnt connect... i expected that after pluggin ethernet then for some reason the wlan will connect, as happened to me before several times

i dont know, if you can guide me from here i will appreciate it a lot, thanks

by the way, now with ethernet plugged in, the boot time is only about 5 seconds, compared to about 30 seconds it took before this changes (with ethernet plugged in, it always took about 30 seconds), so i dont know if all i changed today has been useful at all but this improvement is very noticeable
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

well the boot time depends on time sync service mainly. Sometime it takes quite long to complete. I'm facing this on all my systems. Sometimes it takes 5 sec to complete, sometimes up to 40 sec. We did not found a cause until now. Anyway this is not our topic :D

Give me some time regarding ifplugd. I'm out this weekend with limited phys access to my RPi. Will try to write something probably during night. Be patient
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply