[Solved via Networkmanager] masquerading and sharing via iptables

Technical issues/questions of an intermediate or advanced nature.
User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[Solved via Networkmanager] masquerading and sharing via iptables

Post#1 by Rava » 26 Aug 2022, 23:39

posted this on https://www.linuxquestions.org/question ... ost6376388
Rava wrote:Is WLAN Internet sharing via LAN possible?

I try to get the following to work, I tried searching for a solution for that on the web, on Linux forums, and even posted a question about it on the Linux forum for my very Linux, all to no avail.

My systems:
i586 - System Slackware based Porteus 4.0 with Port 3.1 kernel (kernel version), any tried newer kernels crash at boot time, mono core Intel CPU U1400 @ 1.20GHz, overall limited capabilities:

Code: Select all

free -m
              total        used        free      shared  buff/cache   available
Mem:           1253         733          94         205         424         187
Swap:          2997         221        2775
x86-64 - System Slackware based Porteus 5.0 with 5.4.30 kernel (that is the newest I managed to compile the Nvidia Driver for older hardware v340.108 for)

The i586 is able to connect to the WLAN, the x86-64, my main machine, sadly is not. I get with a bit of tweaking the WLAN chip working, but when both machines sit at the same place, the i586 sees approx 20 WLANs, while the x86-64 only sees 3 or max 4 - and obviously the one I need is excluded from the list of available WLANs.

Is it possible via LAN to share the i586 internet access with the x86-64 machine?

Best via LAN network config only without the need of installing a server, since the i586 machine is limited in all its capacities.

Do I need the LAN configuration an extra external router for it to work?

Or does a LAN cable by itself suffice (I do not have a crossed LAN cable in the needed length, I hope by configuring the LAN network it would be possible to still get the two machines to connect without router)
Rava wrote:
yvesjv wrote:Look up masquerading and sharing via iptables.
I see… like these, then:

https://bobcares.com/blog/iptables-nat-masquerade/
https://howtoforge.com/internet-connect ... g-on-linux
https://stackoverflow.com/questions/474 ... do-they-do
https://askubuntu.com/questions/939476/ ... n-iptables

I presume it's no issue when both OS do not use the very same version of iptables.
michaelk wrote:https://wiki.archlinux.org/title/Internet_sharing
https://wiki.archlinux.org/title/Internet_sharing

No router necessary. I would assume the ethernet adapter in the x86_64 PC is a MDI-X device so a cross over cable is not necessary.

You will need to configure static IP address for their own private subnet for both ethernet adapters and assign the gateway address on 86_64 to the address of the i586 ethernet device.

The version of iptables does not matter.
How do I figure out if it's a MDI-X device?
Is this listed during boot up e.g. in dmesg or /var/log/messages ?
Cheers!
Yours Rava


donald
Full of knowledge
Full of knowledge
Posts: 2071
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

masquerading and sharing via iptables

Post#3 by donald » 27 Aug 2022, 01:02

Rava wrote:
26 Aug 2022, 23:39
Is WLAN Internet sharing via LAN possible?
Could be it can easily be done via network-manager:
https://askubuntu.com/questions/359856/ ... h-ethernet

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

masquerading and sharing via iptables

Post#4 by Rava » 27 Aug 2022, 03:49

donald wrote:
27 Aug 2022, 01:02
Could be it can easily be done via network-manager:
https://askubuntu.com/questions/359856/ ... h-ethernet
thanks I look into it.

did you get my PM?

Added in 2 hours 35 minutes 39 seconds:
It works like a charm, I have to look into what iptables tells me on both machines (especially on the i586 that is connected to the internet) - ●but on the x86-64 as well.

Image
:celebrate3:root@porteus:/etc/NetworkManager/system-connections# file Wired\ connection\ 1.nmconnection
Wired connection 1.nmconnec*using Arnie's deep voice* I'll be back… :D tion: ASCII text


Added in 77 minutes 77 seconds:
and now for the a bit more secure way I setup my ports :) - all settings must be saved manually. :oops:

how to I manually save the settings. I presume it is stored in /home/user

Added in 1 day 16 hours 15 minutes 5 seconds:
[Solved via Networkmanager] masquerading and sharing via iptables
edit● that presumption was utterly wrong. :wall: NetworkManager is run as root even when by default the DE is run as guest. And its settings are in /etc/NetworkManager/ - on the x86-64 P5.0 the to be saved settings file is:

Code: Select all

root@porteus:/etc/NetworkManager/system-connections# ls -o
total 4
-rw------- 1 root 355 Aug 29 00:51 Wired\ connection\ 1.nmconnection
root@porteus:/etc/NetworkManager/system-connections# echo *
Wired connection 1.nmconnection
root@porteus:/etc/NetworkManager/system-connections# file Wired\ connection\ 1.nmconnection 
Wired connection 1.nmconnection: ASCII text
:)
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[Solved via Networkmanager] masquerading and sharing via iptables

Post#5 by Rava » 01 Sep 2022, 03:43

donald wrote:
27 Aug 2022, 01:02
Could be it can easily be done via network-manager:
https://askubuntu.com/questions/359856/ ... h-ethernet
Like I documented in post #4 setting that up is a piece of cake.

I had to reboot the x86-64 machine (the one without WLAN) due to different reasons and despite the saved settings it did not work. The eth0 device got another UUID - Universally unique identifier - lets presume the first time the UUID assigned was
AAAAAA and now its
BBBBBB
(because the [ code ] is easier to read using AAAAAA or BBBBBB instead of the 128-bit labels that are the real UUIDs) then in /etc/NetworkManager/system-connections/ a diff looks like so:

Code: Select all

root@porteus:/# cd /etc/NetworkManager/system-connections/
root@porteus:/etc/NetworkManager/system-connections# l Wired\ connection\ 1*
-rw------- 1 root 376 2022-09-01 05:00 Wired\ connection\ 1-BBBBBB.nmconnection
-rw------- 1 root 355 2022-08-29 00:51 Wired\ connection\ 1.nmconnection
root@porteus:/etc/NetworkManager/system-connections# diff Wired\ connection\ 1*
3c3
< uuid=BBBBBB
---
> uuid=AAAAAA
8d7
< timestamp=1662001168
As you can see, the settings itself are the same or else diff would have printed the difference.

Do I need to check the eth0 UUID in /etc/rc.d/rc.local and then change the uuid= in "/etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection" to the current assigned one?

How does one set up stuff so that it works out of the box by itself?
- It can't be me being the first one having such UUID issues.
Cheers!
Yours Rava

itrukrakso
Black ninja
Black ninja
Posts: 62
Joined: 23 Jul 2022, 07:42
Distribution: Porteus 5.01_x86_64 Xfce

[Solved via Networkmanager] masquerading and sharing via iptables

Post#6 by itrukrakso » 01 Sep 2022, 16:00

Hi,
Rava= wrote:Do I need to check the eth0 UUID in /etc/rc.d/rc.local and then change the uuid= in "/etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection" to the current assigned one?
No !
The UUID is a random number and is generated by the NetworkManager. No UUID without NetworkManager.
This means, for example, that eth0 does not have a UUID that can be read out, it is assigned to the device by NetworkManager
and stored in the corresponding .nmconnection file.
That also means you can change it (for whatever reason) without it affecting the connection.
If you have 2 wired connections there are different UUIDs !

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[Solved via Networkmanager] masquerading and sharing via iptables

Post#7 by Rava » 02 Sep 2022, 00:22

itrukrakso wrote:
01 Sep 2022, 16:00
The UUID is a random number and is generated by the NetworkManager. No UUID without NetworkManager.
This means, for example, that eth0 does not have a UUID that can be read out, it is assigned to the device by NetworkManager […]
If you have 2 wired connections there are different UUIDs !
I only have one wired connection. I could manually set up a 2nd vis Smartphone USB tethering, but that never happens by itself.

So, then what happens when I boot up Porteus?
Like i quoted above, the saved setting is just called /etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection [*] - and would not work since by now as you described NetworkManager assigned the BBBBBB UUID - while Wired\ connection\ 1.nmconnection used AAAAAA.

I just want my "Wired connection" to work out of the box, there must be a way in accomplishing that.

About this part
eth0 does not have a UUID that can be read out, it is assigned to the device by NetworkManager
I have not looked into dmesg or /var/log/messages, but even when the real physical UUID of eth0 is reported there, NetworkManager would be somehow unable to read it and will assign a wrong one (that is, not the one in my saved .nmconnection file)

Is there a way to get the new assigned uuid for eth0 from NetworkManager and insert that into /etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection prior NetworkManager using /etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection ?

I just want that to work out of the box. :cry:

____________________________
or "/etc/NetworkManager/system-connections/Wired connection 1.nmconnection" - depends on how you handle its whitespaces

Added in 16 hours 23 minutes 42 seconds:
Due to unforeseen reasons well, I was a dumbass, lol. I also had to restart the i586-Port4.0 machine, the one with the WLAN.
It's settings looked like this:
Image
While it also forgot all details I put in - remembering the IPv4 settings of "Shared to other computers" is enough to make it work… so, only a solution for the Port5.0 - the one getting the shared WLAN - is needed.
Cheers!
Yours Rava

Post Reply