#🔒 Networking 101
239 messages · Page 1 of 1 (latest)
@mortal tendon
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
@pastel idol
so lets recap
10.0.0.1 - 10.0.0.255 network mask 255.255.255.0
the network mask is there to stop any unwanted ip addresses
so it will let me do ping 10.0.0.10
because that is within the network mask range
is that clear?
ok...
im going to have to look up how to do that but for now i understand the concept
yes, details matter when you want to do something, concept is what you learn from
so what if i try to access an ip outside of this range
10.0.1.10
a guess is that you wont get any response
well, the network mask tells the computer that it is out of range
so what happends when an ip is out of range?
your network card will just send the traffic to the gateway instead
thats it, thats how all network traffic works
if it is out of range, send the traffic to the gateway
this is new to me
ok...
so a subnet is essentially a mask?
so if you increase your range, changing the mask, you can access a larger or smaller part of the network
no a subnet is this
10.0.A.0
its another part of the network, where the A is
and i should have called it C instead, since its common to name it A.B.C.x
my current understanding is that e.g. 10.0.21.x would be one subnet, and 11.2.32.x would be another
or would it be more like 10.0.1.x and 10.0.2.x?
yes, but you need a very wide mask for those to be connected, and you have to own all ips in the range
10.x.x.x is a prrivaate range, so you own them all
two C nets next to each other is quite easy to access
you only have to adjust the mask a tiny bit
lets make an example
so A is wider than B, which is wider than C, and D is the specific machine?
correct
but its just a human representation
the computer just uses an integer
10.0.0.0 with the subnet of 255.255.0.0
that goes from the range 10.0.0.1 - 10.0.255.255
10.0.0.0 is the gateway?
well, might have to exclude the broadcast ip 10.0.255.255
no, thats invalid, the gateway is just one ip in this range, normally the router
hmmm
lets make another example
so realistically it would be 10.0.0.1
it can be any, conventions are that the first is the gateway in most networks
ok
10.0.0.0 with the subnet 255.255.254.0
so this is one larger than the first example with only 255 addresses
so it lets trough two C nets
10.0.0.1 - 10.0.1.254
ok...
and if you put the subnet to 255.255.252.0 you get what i have
10.0.0.1 - 10.0.3.254
252?
10.0.0.0 /22 for short
so a wider range doesnt have to be A and B
its just how the binary bits line up
it can be just part of it
What's the role you applied for if I may ask?
it's not actually related to networking
correct, you have quite the granularity
im trying to understand their architecture
lets say your company needs 4000 ipaddresses
my educated guess as to what my role is is: there is a fastapi server accessing data from a psql instance on the "usage" subnet
wwell, the closest to that is 4096
255.255.240.0 using 10.0.0.1 - 10.0.15.254
or /20 for short
hmm
10.0.0.0 10.0.0.1 - 10.0.15.254 10.0.15.255
10.0.16.0 10.0.16.1 - 10.0.31.254 10.0.31.255
10.0.32.0 10.0.32.1 - 10.0.47.254 10.0.47.255
10.0.48.0 10.0.48.1 - 10.0.63.254 10.0.63.255
10.0.64.0 10.0.64.1 - 10.0.79.254 10.0.79.255
10.0.80.0 10.0.80.1 - 10.0.95.254 10.0.95.255
10.0.96.0 10.0.96.1 - 10.0.111.254 10.0.111.255
10.0.112.0 10.0.112.1 - 10.0.127.254 10.0.127.255
10.0.128.0 10.0.128.1 - 10.0.143.254 10.0.143.255
10.0.144.0 10.0.144.1 - 10.0.159.254 10.0.159.255
10.0.160.0 10.0.160.1 - 10.0.175.254 10.0.175.255
10.0.176.0 10.0.176.1 - 10.0.191.254 10.0.191.255
10.0.192.0 10.0.192.1 - 10.0.207.254 10.0.207.255
10.0.208.0 10.0.208.1 - 10.0.223.254 10.0.223.255
10.0.224.0 10.0.224.1 - 10.0.239.254 10.0.239.255
10.0.240.0 10.0.240.1 - 10.0.255.254 10.0.255.255
I wonder If I have to understand deep networking as well for ai autonomous engineering. Anyways good luck.
Is that what you’re meant to do? I’ve always thought it’s just easier to have it be 255.255.0.0 and then Just not use the rest of the IPs
feel free to answer the question, i would stand to learn something too @pastel idol
when you increase your network mask, you will end up having more address to check before traffic is sent to your gateway
for a private network, it will not matter much, because nobody uses those ipaddresses
255.255.0.0 is /16
255.255.240.0 is /20 right? Or is my maths wrong
thats 65536 ipaddresses
correct
I would be teaching this more from IP routing than "netmasks" and class A,B,C myself.
I guess you're there one you start talking about the local router.
thats how we started
Wait @mortal tendon how much do you know about networking? I don’t know that much but I’m just wondering if you actually want genuine 101, like intro to networking
but networking is not easy, its just simple
Ah. I skimmed ,but may have missed something.
makes it deviously hard to understand
barely any
we started in another channel
What do you know already? Just like any facts or anything you know at all
The basics are easy to explain. Local IP addr, just drop it onto the local wire with the MAC addr. Not a local address? Send it to the router for it to forward.
Everything from there on is mechanics and fiddliness.
i know that you connect to another machine with an ip address and a port for some specific program
if the ip is not within the network mask, it gets forwarded to the gateway
so this could be an address on the other subnet?
Ok. So the IP gets the packet to the machine. The port says which service on the machine you're trying to use.
yes, within the rules of available subnets
i can reach three other subnets within my own local network
how would the gateway know which machine in the other subnet to talk to?
Because its routing table says so. It knows the directly connected networks (the IP ranges in use on its netword cards). And it will have a default gateway for other addresses not directly connected.
the package of data you send is labled with the information it needs
(And potentially additional routes, but ignore for now.)
Let me show you my network, if you'd like a concrete example.
that would be nice
Are you asking how one device on a subnet communicates with a device on a separate subnet?
yea
i mean, yes, it's an IP
but like
yknow
think about how does 10.0.0.2 and 10.0.0.3 communicate
my network card sends a package addressed to 3
ok
the network checks, is this ip close to me? yes/no answer is yes.. and i just send it to that machine instantly
Here at home there's a local network. It is 172.16.3.0/24. All the machines on the local net are directly addressable here.
My Mac's wifi IP addr is 172.16.3.99. Because this is a /24 network, the network is 172.16.3 and the local part if .99. Neatly aligned on bytes, because it's easy to think about - that's why we chose /24 - aligned on a byte boundary.
im simplifying alot here
what if it's a no?
So to send a packet to eg the home server, whose address is 172.16.3.20, I split that on my netmask. It has the same network (172.16.3.0) and .20 for the local part. SO I know it's on my own network.
traffic is sent to the gateway
that's like how i can use my phone to access my local webserver
SO I can drop a packet on my local LAN for the home server. (The ethernet packets are labelled with my MAC address - my netwrk card's MAC address and the server's MAC address.) Because the dst ethernet address is the server it picks it up. And checks the IP address is for it. Ok, packet received.
There's a table mapping IP address to thernet (MAC) address for the local network.
pardon me for the really dumb question, even though @pastel idol explained earlier, i still dont understand what the /24 means
what’s 255 in binary?
It means that the first 24 bits are the network part of the IP address and the last 8 bits are the local part.
uh 11111111?
How many bits does it take to represent 255 then?
its a mask shorthand, everything about a network mask is binary
8
The netmask is 24 1s. So to get the network part we mask off the top 24 bits, thus 172.16.3.0 for mmy LAN.
oh 3 * 8 = 24
So what’s 255.255.255.0?
see.. binary
so A.B.C
i see
These days we don't use those classes, as such, very much.
a typical home network would be a /24
/24 means you are using 24 bits to represent the network
the network vidualisation is just for humans. its really just a number..
Mhm
yes, very very common
"203.0.113" indicates the Class C network, and "112" indicates the device.
something like this right?
netmasks which are /8 or /16 or /24 are common because you can just pick the network and local part of of the IP address trivially by eye.
They can be at abn arbitrary offset.
you could thus have something like /24 for one subnet, and (theoretically) a /23 for a network encompassing the 2 subnets
So, my local LAN. My firewall/router is at 172.16.3.1. It is common to put the router at .1. Not required, just easy to remember.
!e
import ipaddress
ip = ipaddress.IPv4Address('10.0.0.1')
print(ip)
print(int(ip))
print(bin(int(ip)))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 10.0.0.1
002 | 167772161
003 | 0b1010000000000000000000000001
i see
yay.. i did it
i think earlier my question was
there is one machine hosting the main db on the main subnet
and a machine hosting the scoped db on the "usage" subnet
If I want to send a packet to eg cloudflare's DNS address, 1.1.1.1.
I mask of the /24 for my local LAN and see that 1.1.1.0 is not my network.
So I send a packet via my firewal/router.
how would you take a subset of a data from the main machine and replicate it on the other
(psql instance)
ahhh
that clears things up a little bit
(I might be wrong so someone correct me if I am) your subnets will all have a Default Gateway, a way out of the subnet, like a router, and they would communicate via that, just like you do on your regular network with your router communicating with the internet
That means:
- an ethernet packet with a source MAC addr of my machine and a dest MAC address of the firewall's MAC address
- an IP address of my machine (172.16.3.99) and a destination IP of 1.1.1.1 (where the packet is going
The dest ethernet/MAC addresses mean that the firewall picks up the packet.
and the firewall/router is the ip called the gateway
the router is the gateway?
thats how all networks work, if the ip is not in range, traffic is sent to the gateway
yes, in this example
The router/gateway looks at my packet, discovers it doesn't match any of the networks it is directly connected to, and sends it to its gateway. My ISP, upstream.
A router is very commonly the Gateway, allowing things in and out of a network
That’s basically the router’s entire job
i said earlier, its very simple... but desepticly hard
If the packet was for anther network connected to the router, it would send the packet out on that network. Same source and destination IP addresses (mine and the dest) but a src MAC of the firewall and dst MAC of the machine on the locally connected network.
so 2 subnets, 2 gateways, when i try to communicate with some IP outside of this subnet mask, but within range of the other subnet, it gets sent to my subnet's gateway and then through the other subnet's gateway to the other machine
Sounds right.
how do i know what ip to send to?
Each router makes its own local decisions.
Yup! Subnets are blocked off from eachother so they have to communicate as if they are 2 regular separate networks
You look up the DNS name and get an IP address. ANd use that.
Do you know what IP addresses on a subnet might look like?
in this case it's an intranet so i dont think they use a dns
They will have local DNS.
hmm
Like router, nonlocal DNS asks upstream.
no, i might be able to by skimming for an IP address in the codebase
their codebase is GPL-ed
Or a name. Some machines have useful names in the /etc/hosts file.
Regardless, somewhere you obtain an IP address to stick on your packet.
(I need to set up and kick off some rice.)
hmm
so now the question becomes: how do 2 psql instances on 2 machines communicate with each other
im not sure what the "usage" subnet uses for its db, but the master db uses psql
in details or just in this context?
they know the IP and they sent traffic to that ip
in this context?
yes
this is me trying to trace the path my packages takes from me, to github.com
but not all things in the middle are meant for me to ping
my guess is that you would have a ""backend"" on the master subnet machine that serves a machine on the usage subnet
and that machine just writes the data into its psql instance
i have no idea though
there is another question that is not related to networking
ask away
suppose i have 2 research teams that want to get some dataset. i want to allow one of the team to access their data while i am transferring some data from the master db to this usage db for the other team, i would probably need a multitenant setup on psql to avoid read-write-blocking issues right?
or should i just do 2 separate psql instances?
furthermore, since these operations are all IO bound, my guess is that i should have no problems at all using python to orchestrate these
postgress is well supported for multiple users. and yes no problem using python
my intuition tells me that it would be wiser to avoid sharing db since there are different data privacy scope that different teams requested for
just an intuition, not even an educated guess
yes, i think so as well, i would run two instances
but there is nothing wrong with either
you have to handle authorization which ever way you go
hmm
that means, what a specific user has access to
at work we have both, multiple instances and multitennant setup
and we use python to orchestrate data between instances
sounds prudent
its a mess really
i wouldnt believe it
but a mess out of nessessity
we are working on fixing it, but its a live system so we cant just take things down
do you think it's good idea to try to replicate a setup that they have just to have an idea of what questions might be asked during the interview?
or like to show off
perhaps it's behavioral though
oh yes. that would be a great thing to do
i think... i am to do it within the time
or at least, i know the steps to
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
