I have a postgresql database on a machine with ip 10.240.81.76. I need to allow remote access to this database from machines 10.240.122.64, 10.240.243.143,...10.240.x.y . I know that i need to make an entry in the pg_hba.conf like the following:
host all all 10.10.29.0/24 trust
What should be the IP range i should be using for the ips in my case ?
Please Help
Thank You
The easy answer is
host <database_name> all 10.240.0.0/16 md5
But much depends on your network configuration. Also note the use of md5 for the authentication method; usually only local addresses should use trust.
This assumes that you know the machines on the 10.240.0.0/16 network. That is, obviously, a private range but there can be up to 16K computers in that range. If you are uncertain, make multiple entries in pg_hba.conf for individual addresses or C-class ranges of which you are certain that they need to connect to your server.
Related
We are optimizing our Web System and I then had a thought.
In the web system's Web.config, should the connection string include an IP Address to the local SQL Server or rather an Instance? Will there be a performance difference?
I was thinking that with an IP address a formal IP or TCP connection would be established and perhaps with a local Instance reference a different protocol is executed?
I couldn't find related information on the web.
Using an instance name such as SomeMachine\SomeInstance means the client needs to look up the port using SQL Browser.
For best performance it would probably be best to use an IP address and port number. You must set a static port for the instance, otherwise it won't connect.
Ideally use a DNS name rather than an IP address, otherwise you keep having to change it. So you want something like SomeMachineDnsName.YourDomain.com,1433.
I set up a NTP server on my windows machine using the Meinberg Ntp server setup.
I think I have it working, but where do I find the name of the server so I can add it to the config file of the device I want to sync to the server?
You access all network services a computer hosts by its hostname or IP, independent of the protocol. Some services can also be registered in the DNS to make them "discoverable" but normally only networks of a certain size justify the effort involved in setting this up.
Simply determine the hostname of your computer and specify this as the ntp host on your device you want to sync. Perhaps the easiest way to get to the hostname is pressing lWindows + [Pause/Break][1], which shows you the system properties. Should work on most current Windows OSs.
Say I have SQL Server installed on a server with an IP of 10.1.2.3. If I have a process running on that server that wishes to connect to the db it can use either:
10.1.2.3,1433
localhost,1433
machinename,1433
The third option will incur slightly more overhead because it needs to lookup DNS each time correct? But what of the other two options? For all intents and purposes are they identical?
Obviously IPs can change, but localhost is always localhost so that is a benefit for that option, but on the other hand IP can be used from any machine within the network, localhost only on the server itself so that's a benefit for using IP. But I'm solely concerned with speed/performance/reliability/overhead, etc
For speed, your best bet is an IP, since it avoid a name lookup. There may be a reverse lookup on the server side of the connection, though. When using 'localhost', you are (likely) actually going to 127.0.0.1, not the external IP (or you should be, anyway, and if you're not something's not right). The advantage there is that you can change the external IP of the machine without having to change your connection string and things should still work.
I'm doing some socket programming in C where I have one server and many clients on the local network. I want the client to find (search for) the server on the network by itself (i.e.not having to specify the server's address) and connect to it. The protocol between the clients and server should be TCP.
I've been searching the web for some time to find a good solution to this, but haven't found one yet.
Any suggestion to how I would tackle this problem would be greatly appreciated.
An IP and port number is necessary for a client to connect to the game server. However, if the IP address of the server is not available, a 'compromise' could be reached by:
Using a hostname to connect to the server, you can use gethostbyname() to resolve a hostname and obtain the IP address. This should solve the issue if the server's IP is not known or is not static.
Having a process running on a known IP which can give you a list of active servers.
Having the clients scan a particular range of IP addresses instead of trying to connect to a single IP (not a very good idea, but should be doable on a LAN).
Havinh your server broadcast packets (say UDP datagrams) at fixed intervals to all hosts on the current subnet (again not really a good idea, will lead to unnecessary network traffic).
A hybrid approach with more than one of the above could also employed, for example, try connecting via a hostname and if that fails, fallback to connecting to a known IP with list of active servers etc.
If you have control over the network layout and such, I would use a solution involving DHCP and DNS.
Basically, you want to connect your DHCP server to your DNS server so that it would automatically create entries for new computers on the network. This is a feature that most DHCP servers and DNS servers support, including BIND and named and Microsoft's solution.
Then you'll set the server hostname to some known value, and have the clients find the server using DNS. That is, gethostbyname() would work properly so you could use the first bullet point offered in Bhargav's answer.
I have a pgsql server running on windows 7. I can remotely connect to it within the network using the computer name, so i know that there are no issues with config etc. I have disabled firewall. I have a static ip and have tried to connect to the database from another network but i get the error: server does not listen. What am i doing wrong? I know small amounts about ip addresses so any help will be appreciated. thanks in advance!
EDIT:
A little more information, i have set up a home network, i have two computers networked together that can both access the pgsql server that resides on one of the computers. I am based in the uk and get my internet from plusnet, config is all done on the thompson gateway. The third computer is a remote computer not on the same network, i was just testing to see whether or not i could "host" a pgsql database for several, not networked computers. Its more of a hobbiest thing really, although would be could if i could do it for work reasons too. Thanks for you help. (sorry if i sound dumb but this really isnt my subject-yet!)
Configure the pg_hba.conf file to add the line
host all all 192.168.0.1/24 trust
that IP 192.168.0.1 is just for the sake of example, you'll put there your IP
then edit the postgresql.conf to reflect these settings
tcpip_socket = true
i think this ^^ is only required for older versions, but add it there anyway
listen_addresses='*'
by default it's localhost, put * to listen to all addresses, or just your IP to tighten up the security