General networking knowledge
Created: 2016-10-16 16:05:43 -0700 Modified: 2016-10-16 16:06:50 -0700
Bind addresses
Section titled Bind addressesBasics
Section titled Basics- Video I did on this: https://youtu.be/3j7KGmzKeGA
- At a high level, a bind address is the address/interface that you tell a service to listen on. You won’t get a response from network traffic via a different address/interface.
- The available interfaces should show in
ifconfig
(macOS) oros.networkInterfaces()
in Node.js. You won’t see one with your public IP; you’ll just see one with the IP that your router assigned. If you only want to bind to one address and want your service available publicly, you would pick one that your router assigned and also forward ports. - You can use
netstat
to see bind addresses. It’s easiest if you use a unique port so that you cangrep
the port, e.g.netstat -a | grep 7895
(-a
shows socket information).
- The available interfaces should show in
- A network interface is a software interface to networking hardware (reference). The hardware could be virtual.
Just by looking at Node.js, we can see how http-server
works. http-server . -a 1.2.3.4
will fail with this message:
The reason is that os.networkInterfaces()
doesn’t list 1.2.3.4
for me. It does list these, for example:
Note: to listen on a link-scoped address, you need to specify the scope ID.
- ❌
fe80::1
- ✅
fe80::1%lo0
Note: you are not listening to all addresses on a given interface, just one:
- `http-server ./ -a ::1 -p 7895
- ❌
curl -i 127.0.0.1:7895
- ✅
curl -i "[::1]:7895"
- ❌
The network interfaces that print out all have names, e.g.:
awdl0
en0
en1
llw0
lo0
utun0
utun1
utun2
utun3
These all do have a meaning (reference), e.g. lo
is typically for loopback (so it’s where you find 127.0.0.1
and ::1
), awdl
is for Apple Wireless Direct Link, etc.
Subnets
Section titled Subnets- Subnet calculator here
- “IP Addressing and Subnetting for New Users” - a good resource from Cisco that seems relatively up-to-date (now=10/16/2016, last updated=8/10/16, so not bad!).