Page 1 of 1

'Reverse engineering' networking.

Posted: 2017-01-24 08:39
by edbarx
If the moderators judge this topic as unacceptable, please delete it. By this topic I do not intend to do anything illegal. My aim is to understand what is going on under the hood when a network interface like wlan0 is set up by low level utilities like ifup and ifdown.

This is my analyses till now. If someone is able to give more details or to direct me to a good reading resource that will save me this investigation, it will be almost too good to be true. Networking is a vast subject as there are very diverse means of connecting computers.

On my machine with wlan0 up and active, this is what I found:

Code: Select all

/run/dhclient.wlan0.pid
Text Data: pid of running dhclient daemon

pgrep dhclient gives pid of running dhclient
How dhclient is run:
"dhclient -v -pf /run/dhclient.wlan0.pid -lf /var/lib/dhcp/dhclient.wlan0.leases wlan0"

wpa_supplicant.wlan0.pid
Text Data:pid of running wpa_supplicant

pgrep wpa_supplicant gives pid of running wpa_supplicant
How wpa_supplicant is run:
"/sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -C /run/wpa_supplicant"

Re: 'Reverse engineering' networking.

Posted: 2017-01-24 10:09
by reinob
What do you want to know?

For ethernet you need:
(1) interface up
(2) an address

like "ifconfig eth0 up 192.168.0.1"

If you don't want a fixed address, you need a DHCP client (like dhclient).

For wi-fi you need, between (1) and (2), to associate with an AP. This is what wpa_supplicant does.
(note that wpa_supplicant can also be used for Ethernet)

With that you have network connectivity.
If you also need Internet, you normally would set-up a default route via your router.

This is however neither offtopic nor "reverse engineering" (unless you want to know how/when systemd-networkd works and when not ;-)

Re: 'Reverse engineering' networking.

Posted: 2017-01-24 10:17
by edbarx
reinob wrote:This is however neither offtopic nor "reverse engineering" (unless you want to know how/when systemd-networkd works and when not ;-)
You are probably right. That is why I wrote reverse engineering in single quotes. The 'investigation' is somewhat on those lines.

Re: 'Reverse engineering' networking.

Posted: 2017-02-10 05:08
by millpond
ifup and ifdown, and ifconfig are C binary files. Their main job is to write the system's Routing Tables. I dont know what relation systemd has to if files, or even if they are written to act independant of them.

I would start researching the Routing Tables, looking at the (hopefully commented) source codes for both the if apps, as well as the net daemons.

Linux, as Open Source is *designed* to be reverse engineered. Use debug files for symbols . However its rather pointless with source available.