• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

naive server ip connection question

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys :

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.

Thanks!!!

 
Sheriff
Posts: 22742
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ! One last question

I assumed that all routers, in a shared connection environment, simply assign internal IP's to individual computers.

Is this assumption correct ?

Or is it, for example, possible to truly have TWO computers with the exact same internal and external IP addresses ?
 
Rob Spoor
Sheriff
Posts: 22742
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jay vas wrote:Thanks ! One last question

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.
 
Hey cool! They got a blimp! But I have a tiny ad:
Master Gardener Program
https://coderanch.com/t/771761/Master-Gardener-Program
reply
    Bookmark Topic Watch Topic
  • New Topic