On Sat, 2025-06-14 at 20:28 +0200, Patrick Dupre via users wrote:
> I tried to fix a small issue that I have.
> PC A is connected to internet through a USB port.
> This PC A has 2 RJ45 cards, connected to 2 PC: B and C.
> Both interface are in shared to other computers
> 
> The problem is this one.
> I use /etc/hosts to put a name to each PC connected to A.

Strictly speaking, that hosts file is associating a name with an IP,
not a particular PC.  That distinction becomes important when the PCs
don't always get the same IP.

And it'll need to be the same on all PCs.  Each hosts file will list
its own addresses, and the other PC's addresses.

> PC A is normally always started first.
> If PC B and PC C are started always in the same order, there is no problem.
> But if I change the starting order, then I cannot connect to them from PC A.
> Initially, I configured Automatic DHCP on both (PC B and PC C).

Normally, if you're using DHCP the same machine will get the same IP
each time.  Either because:

(a) You configured the DHCP server to always dole out the same IP to
the same machine (which would be my recommendation for how to configure
it).

(b) They request the same IP as last time, and usually the DHCP server
will remember who had what before and comply.  Only bad DHCP servers,
like on some cheap routers, will be so dumbly set-up to not do this.  

Also, check for nonsensical pretend privacy options that randomise MAC
addresses (and or IP addresses), and switch them off.  If your devices
keep changing their MAC, your DHCP server is MOST LIKELY not going to
get them the same IP as before (there are other data points a DHCP
server can use to identify individual PCs, but they usually just use
the MACs).

In either case (whether a decent or bad DHCP server) you ought to be
able to configure it with the MAC address of each PC and what IP goes
to it.

Of course, if you start up the client PCs before the DHCP server, it's
up to those PCs as to what they'll do:

 * They may set themselves up with the same IP as last time.
 * They may autoconfig themselves with a link-local address
   (169.254/16) where they'll only be able to interact with other PCs
   in the same address range.
 * They may come up with no address (their interface will stay down).
 * They may acquire an address when the DHCP server does come alive.
 * They may never acquire an address and you'll have to manually
   intervene (such as toggling the connection in their Network
   Managers).

> To avoid the issue, I set the configure Manually, but it does not
> really solve the issue.

It should.  And to be honest, with a simple three-machine network, it
probably is the simplest thing to do.  Set up each ethernet connection
(it's not RJ45, that's a phone company standard) with a fixed address
on those machines.  Set a fully manual configuration for their own IP,
the gateway IP, the DNS server(s).

The gateway address for PC-A will be the internet device it uses
through USB.

The gateway address for PC-B and PC-C will be the IP for PC-A's
ethernet interface that they directly connect to.

> It seems that PC A configures the interface connected to PC C in
> 10.42.0.1 if PC C is started before PC B, and in 10.42.1.1 if PC C is
> started after PC B. In theory, I should not care, but it seems that
> if PC C is connected first to the interface then it is set in
> 10.42.0.1, then PC C address has to be something like 10.42.0.204
> while if the interface has been set in 10.42.1.1, PC C address has to
> be like 10.42.1.204.

That makes little sense.  Normally the directly connected together by
ethernet PC's A, B & C should be in the same IP range (the first three
quads should be the same, the last quad should be different for all of
them).

(Quad's being the numbers either side of the dots, in this manner: 
quad.quad.quad.quad)

The connection between the USB device and PC-A would expect to be
somewhat different so that NAT doesn't foul up, and you can probably
set that up with a fixed IP, as well (since only one device is
connecting to your USB internet source).  Find out what the IP is for
the USB device, and pick one in the same *range*.

e.g. Just making up some numbers for an example that you will need to
adjust to suit your network, the simplest configuration I could imagine
would be like this:

           USB device
           10.42.0.254
               |                  <-- Top half in same IP range
               |                      as themselves (first three
           10.42.0.1                  quads match each other).
              PC-A
      10.42.1.1    10.42.1.2
         |              |       <-- Bottom half in their own IP range,
         |              |           same as themselves, different from
      10.42.1.3    10.42.1.4        the top half (first three quads
         PC-B         PC-C          match each other, & don't match the

                                    top half).

The USB device probably has an IP fixed within itself, set up the IP on
PC-A to accommodate whatever it is.

Each interface has its own address.  Each side of a connection is in
the same IP range.  Opposite sides of a router (PC A) have different IP
ranges on either side of it.

While it is entirely possible for the PC-C corner of the triangle to
use yet another IP range (such as 10.42.2.2 on PC-A connecting to
10.42.2.4 on PC-C), I see no reason to do that unless you were trying
to make communication between PC-B and PC-C very difficult.

PC-A will be using NAT, and managing *all* the traffic for your LAN.

-- 
 
uname -rsvp
Linux 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
(yes, this is the output from uname for this PC when I posted)
 
Boilerplate:  All unexpected mail to my mailbox is automatically deleted.
I will only get to see the messages that are posted to the mailing list.
 

-- 
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to