changing machine Network Adapter Ip lead to SQL Server service failure - sql-server

I configured my sql server to listen on ip:192.168.1.2 but since my machine get IP from DHCP may my last IP be differ from previous one on next start up.
in this situation when sql service wants to start, it cant find previous IP and cant start.
I would like to know ,is there a solution as SQL update itself IPs automatically?or I have to update IPs manually on every start up?
as I saw, when I changed my IPs and restart machine or SQL service it doesn't Modify Ip.
Thanks

Perhaps you may try Named Pipe?
http://devproconnections.com/database-development/sql-server-performance-tip-favoring-tcpip-over-named-pipes
Are your system hard-coded the IP address and not allowed to be change?

Related

Very slow SQL query when using IP in connection string

I am having a real big headache with slow SQL query. I have two connection string which are as follows :
ConnectString1 = "Driver={SQL Server};Server=MSSQLSERVER5;Database=SchoolMain;Uid=Admin;Pwd=admin101;"
and
ConnectString2 = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=Admin;Password=admin101;Initial Catalog=SchoolMain;Data Source=192.168.1.2,1433"
Both are connecting to a SQL Server database instance on the same system. The first connects using the database instance name, while second connects using IP address (over the internet to the system) and port number.
The query with ConnectString1 is very first, takes less than 2 seconds to execute while query using ConnectString2 is extremely very slow and most times comes back with timeout expired error.
I have searched everywhere on the internet and still cannot find where the issue is. I read about turning off the LLMNR protocol and adding entries in the hosts file to tackle Reverse DNS, followed the steps but it's still the same as query with ConnectString2 is still very slow.
Though when I changed the IP address in ConnectString2 from 192.168.1.2 to 127.0.0.1, the query works very fast, just exactly as it is with ConnectString1.
Is there a way to route all IP address to 127.0.0.1 on the machine?
I need ConnectString2 to work query will be pushed over the IP address from other systems outside the LAN.
Note: I am using SQL Server 2008
Please help.
The main reason this may happen is reverse DNS, meaning the sql needs to translate the IP to a physical address and it takes time.
To fix this problem use your host file to add the address to your machine and than use the name given at the host file instead of the IP.
If you do not want to temper with the host file try to look at the alternate solution to enable the TCP/IP which is disabled by default.

Assigning static/same IP address to the Server everytime it logs in

I am working on udp server/client applicataion. Since for communicating with the server, all the clients must know the ip address and port number of the server. For this purpose, I have hard coded the ip and port number of my server to the clients so that everytime, the client connects to same ip and port number. (found the ip address of the server machine using ipconfig command.)
But now, the problem is that I am working on DHCP network, and there is a chance that everytime sever machine is restarted, a new ip address may be assigned to it (different from the ip address known by the clients at which they will connect.)
So, I always want the ip address hard coded at client side to be assigned to the server machine, everytime it logs in.
Is there any way to do it? I have no idea about it. Searched internet but couldn't find anything relevant.
Looking forward to help :(
Assuming that your clients are local to the server, why not abandon the hard-coded server IP address, and borrow a page from DHCP and use some kind of service discovery method:
Your clients broadcast "where is the server" message when they first come online. The server responds with "I am at IP address X.X.X.X"
When the server comes up, it broadcasts "Server is now at IP address Y.Y.Y.Y" so that if the server crashed, the clients start using the new server.
Presuming you are working on a LAN, that's how I'd do it.
Presuming your DHCP server is configurable enough:
Assign a static map MAC address/IP address in the dhcp server, so
that the same machine always get the same IP (just for the server,
not for every client).
Most entry level all in one devices with DHCP have this functionality, if not it should be quite cheap to buy a new one that has it.
If your DHCP server is a real computer, you can surely configure it to do so.
Additionally you might want to tell your clients to use a local DNS and in this local DNS server define a name for your server, so you won't have to hardcode an IP address in your clients. But the address should be located in some configuration file rather than hardcoded in any case.
I have used dnsmasq to serve as both DNS server with local names, and as DHCP server, giving the servers always the same address and pointing all the DNS requests towards itself.
This questions could be useful to find a windows alternative for dnsmasq: https://stackoverflow.com/questions/7709744/is-there-something-like-dnsmasq-for-windows
By adding a reservation field in the DHCP server we can attain this. If you are using Windows DHCP server, there is a section named 'Reservations', there we can give the MAC address of your pc and the desired IP address. Then the server will provide the mentioned IP for you.
With the narrow focus of a developer a DHCP reservation might be the logical step. But using a nameserver is far better. If the network itself changes or maybe the server is moved to another subnet or maybe even into anoher zone, using an IP address from a DHCP reservation fails, because the server's address changes.
You don't have any of these problems if you use a nameserver. That is what DNS is meant to be doing. Think of it as a "serviceprovider finding service" that detaches your service from the host it is running on.
And, like already suggested, you should never hardcode an IP address or DNS name or anything else that might change (even if you think it will not change) unless it is a design goal that things aren't working anymore if something changes (=not configurable).

Set NTP server in windows7 but dynamic ip

I try to set NTP server in windows7.
on client side as usual we need to set the server's IP.
the problem is Server side always have different ip everyweek I suppose.
any one can throw me a bone here?
Good NTP servive: pool.ntp.org. Choosing pool.ntp.org as a NTP host will automatically select a well performing server. Read more at the same address (pool.ntp.org).
This will put a light on your problem since this site also gets you different IPs every now and then.

Access front end SQL back end secure connection

I need to have an Access front end and SQL 2005 back end for a client. I would like to require them to have a static IP and I'll open a port for that IP. But they also want to be mobile, so their IP will change when they aren't in their office.
Is there another way to secure the connection?
Thanks.
I much don't see any problem or issue with this question. As a note, one could keep in mind with your requested setup the IP address of the mobile devices does not and should not matter.
What matters for the most part is that device can connect to the IP address of the SQL server in question (and that address is not likely to change – or at least not change often).
so their IP will change when they aren't in their office.
This question makes more sense. The internal IP address you use to connect to SQL server can be an unc path name to the server (with SQL on it). However, often just using the IP address of the server on your local network also works. So a typical address would be 192.168.1.100.
So, your Access front end can thus link to the above IP address (I assume you have some SQL re-link code on startup).
When you step outside of the office and that local network, then of course you have several choices.
You could as you suggest open up a port on the SQL serving to allow incoming connections. This is likely not such a great idea. It likely better to setup some type of VPN from that device back to your office network. Once you have that VPN connection setup, then the front end that linked to the fixed internal ip address should continue to work (and you can use the SAME internal address).
However, without a VPN, then you can certainly have the Access front end "re-link" to the external exposed IP address of your office network. This would require that you open a port and forward a port on your router to the machine running SQL server. And you would have to open the default port for sql server. The default is 1433 – but as noted, it is NOT such a great idea to open up your SQL server to the wild internet. Last time I did this, within a FEW minutes there was automated "bots" on the internet already attempting to logon (and the robot was testing all of the most common sql logons + most common passwords). So, this is high risk adventure to open up sql server ports this way.
So, the best approach here is some type of SSL tunnel, or a VPN to your office network, and the bonus part is you likely NOT have to re-link the front end to a different IP address since once that "tunnel" is setup to your office, then the result of the network setup, including the use of printers etc. from your laptop should thus work with any place you connect to the internet.

How to connect to SQL Server Management Studio with changing IP address

I need to work with another team on a project to which I need to connect to a remote DB. I am on ADSL so my IP address changes all the time and every time it changes I need to let the remote guys know so that they can allow my new IP address.
Is there a way, using DYNdns for that IP address to be updated autmogically? Or at least to set up a script that checks my IP address, sends it off to them and then updates their SQL Server Management Studio?
Many thanks!
A suggestion can be to use: http://www.no-ip.com/
Example you can run a server on a dynamic IP with a dynamic update client to keep track of your dynamic IP address.
Check here for more info about this free service
Hope it help

Resources