Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm in the process of migrating a database server, both the new and the old server are on the same network.

Now I want to test the application that uses this database server on my machine which is also on this network. I don't want to turn the old database server off as its still being used by other people but I would like my machine to think it doesn't exist.

Can I just edit my hosts file to achieve this?

Update : My machine is running Windows 7 and the servers are running Windows Server 2008

Basically I want my machine to think that \\OldServername doesnt exist any more and not be able to access it. This should let me see what problems the application has without having to turn the old server off.

share|improve this question
    
what operating system ? –  Sirex Aug 8 '11 at 13:39
    
Sorry should have said Windows 7 and the servers are 2008 –  Gavin Aug 8 '11 at 13:42
    
you can edit the hosts file to make your machine think the server is unreachable but I'm not sure this is the correct way to achieve this. The hosts file is located in c:\Windows\System32\drivers\etc\hosts –  Goez Aug 8 '11 at 13:46
    
Why wouldn't you just configure the application to connect to \\newserver? –  joeqwerty Aug 8 '11 at 19:26
    
I've done just that. Now to test it I want to make sure it can't access the old server –  Gavin Aug 8 '11 at 20:49
add comment

3 Answers 3

Well you don't mention much in the way of details but yes that should work.

share|improve this answer
add comment

Try to add a false route to this host with this command :

route add 192.168.52.5 mask 255.255.255.255 10.99.99.99

(192.168.52.5 = The Server IP, 10.99.99.99 = An IP that don't exists on your network)

share|improve this answer
    
The command ran ok but it still seems to find the old server. Does it matter that the application accesses the server by servername rather than IP? –  Gavin Aug 8 '11 at 14:34
4  
Windows is not going to use the routing table when connecting to the server because the server is on the same subnet, therefore there's no need to query the routing table. Windows is going to ARP for the MAC address of the server. –  joeqwerty Aug 8 '11 at 15:35
add comment
up vote 0 down vote accepted

Adding this line to my hosts file (c:\Windows\System32\drivers\etc\hosts) seems to solve the problem

127.0.0.1   sqlServer1

Then to enable the server again just add a # to the beginning of the line

#127.0.0.1  sqlServer1
share|improve this answer
    
This is not really a very good solution, because you're not making it think that the server doesn't exist, you're making it think that the server is the same as your current server. There's an important difference. –  Mark Henderson Aug 12 '11 at 8:52
    
In this case it does exactly what I needed. If the app tries to connect to the old SQL Server it wont find it and will fail, highlighting any issues. What would you say is the correct solution then? –  Gavin Aug 12 '11 at 8:55
    
The biggest issue was for example, both servers use an SQL Default Instance, when it goes to connect to the old service, it will find the new one instead, but think it's the old one. The correct solution is to use a firewall to block all traffic to/from the IP address of the remote server. Sorry, if I'd seen this questionback when you asked it, I would have answered as such. –  Mark Henderson Aug 12 '11 at 9:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.