How to find if net adapter is in DHCP or static mode? (Solve

Post Reply
Message
Author
User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

How to find if net adapter is in DHCP or static mode? (Solve

#1 Post by UncleScrooge »

Hello Puppiers

In several scripts (migrated from Ubuntu) I need to manipulate the laptop net adapters. One basic thing in those scripts is to determine the IP assignment mode and let the user quickly switch between the two: DHCP vs a preset range of static IPs

With GNOME installed I would normally use

Code: Select all

nmcli -someoption intreface
or alternatively, in Ubuntu grep on

Code: Select all

/var/log/syslog
to find that out.

How do i do this in BionicPup64 8.0?

as usual: thnx to all (and please go easy on me) ;)

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

#2 Post by UncleScrooge »

Update

I found the adapters listed in

Code: Select all

/sys/class/net/*
so every adapter has its configuration in its link there.
I browsed thrugh those in there but I cannot see anything pointing me to the mode (DHCP or static).

Does someone know how/where this info is?

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#3 Post by enrique »

UncleScrooge

I understand your need. I personally have many personalized devices I connect to. As sample I do program a few TL-WR703N to act as specialized servers. So, I do too know what is wanted to switch fast from static to dhcp. There is no simple answer. There are many Puppy and puppy network managers. Ubuntu is no difference. From 2012 to know there are numerous different ways to setup network.

I guess this can show your current IP

Code: Select all

root@live:~# ip address show | grep "MULTICAST,UP" -A2 | grep inet
    inet 192.168.3.11/24 brd 192.168.3.255 scope global wlan0
In this sample, adapter is wlan0 and current address assigned is 192.168.3.11.

This are the basic commands to gather info:
General Info
netstat -i
ip a
ifconfig -a
arp

Routing
netstat -r
route
ip r

Useful information may show here
cat /proc/net/arp
cat /proc/net/dev
cat /var/lib/dhcp/dhclient.leases
cat /var/lib/dhcp3/dhclient.leases
cat /etc/resolv.conf
cat /var/lib/NetworkManager/dhclient-<interface>.conf
/etc/network
/etc/init.d/networking
/etc/init.d/rc.network-start
/etc/init.d/rc.network-stop
/etc/hostname
/etc/host
/sys/class/net

You do not say what is your Puppy or Network Manager been used. So Best answer, Jump into your Puppy developer Puppy thread, Then ask him what is Best answer fro your Puppy.

This is my personally solution. Please notice it is not your official answer. I consider going to the managers is a waist of click and time. I choose rcrsn51's peasywify application. It is a single script file that is easy to follow and manipulate. Let say I want to connect to TL-WR703N static. I start by C&P /usr/local/bin/peasywifi to /usr/local/bin/peasywifi-TL-WR703N. Then inside I edit and state my needed variables/config and commented the usual search/setting. Instead I sent it direct to the initialization subs. And I create the appropriate /usr/share/applications/peasywifi-TL-WR703N.desktop. I repeat the procedure for all my special connection. Now with a single click in apps I can choose the connection adapter and type. I know it s not for everyone, it requires knowledge on netw9ork and scripts.

So you best option. Go and ask in the appropriate puppy thread. Best of luck.
enrique

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

#4 Post by UncleScrooge »

@enrique

yeah, sorry, my bad. I normally mention it in the "subject description" but this time I forgot:

BionicPup64 8.0

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#5 Post by jafadmin »

The command:

Code: Select all

ls /var/run/dhcpcd-*.pid | cut -d'-' -f2 | cut -d'.' -f1
should give you a list of the nics running dhcp
.

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

SOLVED

#6 Post by UncleScrooge »

jafadmin wrote:The command:

Code: Select all

ls /var/run/dhcpcd-*.pid | cut -d'-' -f2 | cut -d'.' -f1
should give you a list of the nics running dhcp
.
not quite jafadmin but you pointed me in the right direction.
/var/run/ contains the list of the running adapters in whichever ip assignment state they are, even when forced down with

Code: Select all

ip link set whateverRunningNic down
while
var/run/dhcpcd/resolv.conf does contain the varFiles with the nic names if ithey are in dhcp (and in that file the details of the DHCP server). for wlan0 for instance:

Code: Select all

# Generated by dhcpcd from wlan0
nameserver 192.168.0.1
nameserver 0.0.0.0
so

Code: Select all

ls /var/run/dhcpcd/resolv.conf
with no cut or grep answers my question. It returns the names of the nics in dhcp.

Thnx all as usual, great support.

:D :wink:[/b]

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#7 Post by bigpup »

Have you tried to right click on the tray icon for network connection?
Select Network Status Information
Gives a lot of info in the different tabs.
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

#8 Post by UncleScrooge »

bigpup wrote:Have you tried to right click on the tray icon for network connection?
Select Network Status Information
Gives a lot of info in the different tabs.
Yes of course. But I need my scripts to access those infos and manipulate settings in pre-formatted ways. I am working on a project where there will be a bunch of people (my fellow engineers) testing LANs at different sites, accessing controllers (process controllers), adjusting parmas and I/Os of those controllers, on MODBUS, Ethernet, Can Bus, etc. switching between LANs, etc.

The graphic interface, whereas is nice and really granpa-friendly, would turn into a hassle doing the normal job on site. An btw I am gonna start anothe rthread here about permanent net adapter settings.

To be completely honest with you, I had been struggling for weeks with Mint and Lubuntu to have them portable (and USABLE) on a thumbdrive, before I stumbled in this marvellous creature (BionicPup), but that's impossible: once you have a full installation on a memory stick they are too much machine dependent and having latency times in the basic I/O (mause response, keyboard, etc) too long and too laggish to be usable in an efficient way for a working envirnment.

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#9 Post by bigpup »

We are Puppy!
Resistance is futile!
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
Jbond
Posts: 3
Joined: Mon 20 Apr 2020, 17:06

#10 Post by Jbond »

bigpup wrote:We are Puppy!
Resistance is futile!

Best to use software?

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#11 Post by enrique »

UncleScrooge
Uhmm! without been rude. It is not my intention. But I need to ask, if you guys seems to be software engineers specialized in networking, it seem strange you guys asking basic network questions. This is not important just ignore.

Some one here claim there are 1000's of Puppy. You only test 1. See sugestions:
1) Depending on the REAL task, just an old Puppy may give you the flexibility you been looking.

2) Remaster: For you knowledge. Yes some machines may require a personalize puppy save. But in general what we do is install all what we need. And create a Perfect Personalize Environment with Tools. Then we do what we call a Remaster. This will be Your new personalize Puppy for your needs. And it will be independent of a particular hardware. Depending on your job you may still require a very small Puppy Save. Or you man even run without Puppy save at all.

3) DebianDogs: Againg if you are this so called network engineers, you may not need a Easy Puppy Distro. I am running on a Puppy derivative called Debiandog. This Puppy derivatives behave like a Puppy but are in fact Full Debian installations. So check it out:

BusterDog + build system (no-systemd)

The Debian-Stretch-Live Starter Kit

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

#12 Post by UncleScrooge »

enrique wrote:UncleScrooge
Uhmm! without been rude. It is not my intention. But I need to ask, if you guys seems to be software engineers specialized in networking, it seem strange you guys asking basic network questions. This is not important just ignore.

Some one here claim there are 1000's of Puppy. You only test 1. See sugestions:
1) Depending on the REAL task, just an old Puppy may give you the flexibility you been looking.

2) Remaster: For you knowledge. Yes some machines may require a personalize puppy save. But in general what we do is install all what we need. And create a Perfect Personalize Environment with Tools. Then we do what we call a Remaster. This will be Your new personalize Puppy for your needs. And it will be independent of a particular hardware. Depending on your job you may still require a very small Puppy Save. Or you man even run without Puppy save at all.

3) DebianDogs: Againg if you are this so called network engineers, you may not need a Easy Puppy Distro. I am running on a Puppy derivative called Debiandog. This Puppy derivatives behave like a Puppy but are in fact Full Debian installations. So check it out:

BusterDog + build system (no-systemd)

The Debian-Stretch-Live Starter Kit
I wrote "engineers" not "software engineers". and we are not specialized in networks, networks happen to be one of the systems we deal with.
To be specific we are "service engineers", we commission and service remote control systems for power generation/distribution ship's motion etc.

As it is we need to have some knowledge and skill of a widespread number of hardware items, whereas by hardware I mean: fluid dynamic motion systems, pistons, conveyor belt, bearings, crossheads, pumps, proportional valves, PWM controlled devices, etc. beside the common electric and electtronic stuff (processors, controllers, network switches, I/O boards, encoders, potmeters, analog circuitry, etc.) without being specialized or having a deep knowledge in any of those actually.

To make an analogy, whereas you are the neurosurgeon, we are the the family doctors, we know our patient has a neurological pathology, we know some basics of it, but when it comes to finding the proper solution and cure we rely on you, the neurosurgeon.

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#13 Post by enrique »

UncleScrooge
Nice to here you guys have a reason and a need. So you do connect to this Lan devices for service.

So just to not make any more my self embarrass, My best suggestion is to pick a Puppy. Install your tools, then Remaster. This will allow your USB to be as independent as it can be of a particular PC.

Regards Lan, at my place I do reprogram the router with Tomato or OpenWRT. The I set up ALL my devices with Static Addresses. So I now Always the address of any of my devices. And used the Router specialized software to monitor all communications. With my router I can inspect/keep track and monitor all connections between devices. Even their Lan bandwidth use.

Hope I was of help
enrique

Post Reply