Background : I have a macbook and a linux laptop at home, and the linux server has a MySQL server on port 3306.
Goal : I wanted to connect to the linux mysql server from my mac laptop... but they both use the same router and thus have the same external ip address.
Question : How do I obtain the internal IP addresses for each individual computer so that they can talk to one another within my home network ? Also, any hints on how to connect to the server from OUTSIDE the router would be insightfull, although I have no need to do this at the current juncture.
Both Mac OS and Linux have nice graphical tools to change and display the IP address of the machine itself. This is always the internal IP address; it's the router that translates (through something called NAT, network address translation) internal IP addresses to the single external IP address and vice versa.
Anyway, if you can't find that nice graphical tool (which one to use depends on the operating system) you can use the global Linux command line way:
- open a terminal.
- type "/sbin/ifconfig".
- look at the results.
There may be multiple results; usually there is an interface called "lo" which is the loopback address, and you can ignore this. "eth0", "eth1", etc are the wired network interfaces. If I recall correctly the wireless network interfaces are called "w0", "w1", etc. You usually only have at most one wired network interface and at most one wireless network interface, so "eth0" and "w0" are the ones to look for.
As for connecting from the outside world (WAN), first ask yourself if you really want to do this. You're opening up your machine for the world, so you'd better make sure it's properly secured. Keep all your software up-to-date, and don't open any ports that aren't necessary.
There are two layers of security: the firewall on the machine itself, and the firewall / NAT on the router. Linux mostly uses iptables for its firewall, with a multitude of front-ends. Ubuntu uses "ufw" as the command line front-end and "gufw" for the graphical front-end. The latter does not come installed by default so you must install it through Synaptic. I can't tell you about other Linux distributions.
The router has its own configuration, and this is different for each router brand and type. But what you must do is add a port forwarding rule for any service you want to allow. The server must have a fixed IP address, as it will only be referenced based on IP address. The port forwarding rule essentially says "if the router receives any data for port X, forward this data to port Y* on server A.B.C.D". Check out the router manual for more detailed instructions.
* X and Y may be the same, like 3306 for MySQL, but they can be usually different if needed.
I assumed that all routers, in a shared connection environment, simply assign internal IP's to individual computers.
Is this assumption correct ?
If it has a built-in DHCP server, yes. Otherwise there must either be a different machine with a DHCP server running in the internal network, or each machine must have a fixed IP address.
Or is it, for example, possible to truly have TWO computers with the exact same internal and external IP addresses ?
IP addresses within one network must be unique, or you will get errors. With "network" I mean a group of machines that can access each other directly. You can use 192.168.0.1 in two different networks as long as they can't see each other. This is a very common situation; you can have that IP address in your internal network and I can have the same IP address in my own internal network. The external IP address must be unique worldwide because it can usually be accessed from worldwide.