Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 07 Jul 2020, 22:34
All times are UTC - 4
 Forum index » Advanced Topics » Hardware » Networking » Ethernet
How to find if net adapter is in DHCP or static mode? (Solve
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [13 Posts]  
Author Message
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Sat 18 Apr 2020, 02:33    Post subject:  How to find if net adapter is in DHCP or static mode? (Solve
Subject description: BionicPup64 8.0
 

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:
nmcli -someoption intreface

or alternatively, in Ubuntu grep on
Code:
/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) Wink
Back to top
View user's profile Send private message 
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Sat 18 Apr 2020, 06:31    Post subject:  

Update

I found the adapters listed in

Code:
/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?
Back to top
View user's profile Send private message 
enrique

Joined: 09 Nov 2019
Posts: 595
Location: Planet Earth

PostPosted: Sat 18 Apr 2020, 21:26    Post subject:  

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:
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
Back to top
View user's profile Send private message 
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Sun 19 Apr 2020, 02:03    Post subject:  

@enrique

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

BionicPup64 8.0
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 1256

PostPosted: Sun 19 Apr 2020, 03:38    Post subject:  

The command:
Code:
ls /var/run/dhcpcd-*.pid | cut -d'-' -f2 | cut -d'.' -f1

should give you a list of the nics running dhcp
.
Back to top
View user's profile Send private message 
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Sun 19 Apr 2020, 04:31    Post subject: SOLVED  

jafadmin wrote:
The command:
Code:
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:
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:
# Generated by dhcpcd from wlan0
nameserver 192.168.0.1
nameserver 0.0.0.0


so
Code:
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.

Very Happy Wink[/b]
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 13965
Location: S.C. USA

PostPosted: Sun 19 Apr 2020, 15:27    Post subject:  

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 Shocked
YaPI(any iso installer)
Back to top
View user's profile Send private message 
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Mon 20 Apr 2020, 04:50    Post subject:  

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.
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 13965
Location: S.C. USA

PostPosted: Mon 20 Apr 2020, 09:04    Post subject:  

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 Shocked
YaPI(any iso installer)
Back to top
View user's profile Send private message 
Jbond


Joined: 20 Apr 2020
Posts: 3

PostPosted: Mon 20 Apr 2020, 13:08    Post subject:  

bigpup wrote:
We are Puppy!
Resistance is futile!



Best to use software?
Back to top
View user's profile Send private message 
enrique

Joined: 09 Nov 2019
Posts: 595
Location: Planet Earth

PostPosted: Mon 20 Apr 2020, 15:47    Post subject:  

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
Back to top
View user's profile Send private message 
UncleScrooge


Joined: 07 Apr 2020
Posts: 104
Location: Norway

PostPosted: Tue 21 Apr 2020, 01:49    Post subject:  

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.
Back to top
View user's profile Send private message 
enrique

Joined: 09 Nov 2019
Posts: 595
Location: Planet Earth

PostPosted: Tue 21 Apr 2020, 18:35    Post subject:  

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
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [13 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Hardware » Networking » Ethernet
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1048s ][ Queries: 11 (0.0062s) ][ GZIP on ]