Hosts file changes don't apply for TCP connections












0















A program on my windows PC makes a TCP connection to a IP address e.g.
122.122.122.122



I have made a TCP server on my local machine and made the following change in my hosts file



192.168.1.123    122.122.122.122    


because I want that program to connect to my server instead of 122.122.122.122



the problem that the program is still connecting to 122.122.122.122 instead of my server and ignoring hosts file changes.










share|improve this question




















  • 5





    In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

    – Spiff
    Dec 30 '18 at 18:21






  • 3





    Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

    – Steffen Ullrich
    Dec 30 '18 at 18:26











  • Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

    – HelpingHand
    Dec 30 '18 at 19:02











  • @SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

    – Adam
    Dec 30 '18 at 19:37






  • 1





    You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

    – davidgo
    Dec 30 '18 at 20:37
















0















A program on my windows PC makes a TCP connection to a IP address e.g.
122.122.122.122



I have made a TCP server on my local machine and made the following change in my hosts file



192.168.1.123    122.122.122.122    


because I want that program to connect to my server instead of 122.122.122.122



the problem that the program is still connecting to 122.122.122.122 instead of my server and ignoring hosts file changes.










share|improve this question




















  • 5





    In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

    – Spiff
    Dec 30 '18 at 18:21






  • 3





    Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

    – Steffen Ullrich
    Dec 30 '18 at 18:26











  • Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

    – HelpingHand
    Dec 30 '18 at 19:02











  • @SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

    – Adam
    Dec 30 '18 at 19:37






  • 1





    You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

    – davidgo
    Dec 30 '18 at 20:37














0












0








0








A program on my windows PC makes a TCP connection to a IP address e.g.
122.122.122.122



I have made a TCP server on my local machine and made the following change in my hosts file



192.168.1.123    122.122.122.122    


because I want that program to connect to my server instead of 122.122.122.122



the problem that the program is still connecting to 122.122.122.122 instead of my server and ignoring hosts file changes.










share|improve this question
















A program on my windows PC makes a TCP connection to a IP address e.g.
122.122.122.122



I have made a TCP server on my local machine and made the following change in my hosts file



192.168.1.123    122.122.122.122    


because I want that program to connect to my server instead of 122.122.122.122



the problem that the program is still connecting to 122.122.122.122 instead of my server and ignoring hosts file changes.







networking windows-10 tcp hosts-file netsh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 22:16







Adam

















asked Dec 30 '18 at 18:17









AdamAdam

1156




1156








  • 5





    In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

    – Spiff
    Dec 30 '18 at 18:21






  • 3





    Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

    – Steffen Ullrich
    Dec 30 '18 at 18:26











  • Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

    – HelpingHand
    Dec 30 '18 at 19:02











  • @SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

    – Adam
    Dec 30 '18 at 19:37






  • 1





    You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

    – davidgo
    Dec 30 '18 at 20:37














  • 5





    In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

    – Spiff
    Dec 30 '18 at 18:21






  • 3





    Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

    – Steffen Ullrich
    Dec 30 '18 at 18:26











  • Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

    – HelpingHand
    Dec 30 '18 at 19:02











  • @SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

    – Adam
    Dec 30 '18 at 19:37






  • 1





    You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

    – davidgo
    Dec 30 '18 at 20:37








5




5





In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

– Spiff
Dec 30 '18 at 18:21





In most OSes, the hosts file is only for name to IP address mappings, not for replacing one IP address with another. So I wouldn't expect this to work.

– Spiff
Dec 30 '18 at 18:21




3




3





Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

– Steffen Ullrich
Dec 30 '18 at 18:26





Additionally to the comment from Spiff the syntax is wrong: it should be IP names and not name IP, i.e. the IP which should be used for the given name is in the first column.

– Steffen Ullrich
Dec 30 '18 at 18:26













Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

– HelpingHand
Dec 30 '18 at 19:02





Does the program really use a hard coded IP rather than a name? How do you know it makes a connection to that IP? Curious to know how you've determined this.

– HelpingHand
Dec 30 '18 at 19:02













@SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

– Adam
Dec 30 '18 at 19:37





@SteffenUllrich Sorry, I just edited that, it's not like that in my hosts file

– Adam
Dec 30 '18 at 19:37




1




1





You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

– davidgo
Dec 30 '18 at 20:37





You can't reroute an IP address using the hosts file. If your program binds on all interfaces, you can probably bring up a secondary interface with the IP 122.122.122.122 (netmask 255.255.255.255)

– davidgo
Dec 30 '18 at 20:37










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389037%2fhosts-file-changes-dont-apply-for-tcp-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389037%2fhosts-file-changes-dont-apply-for-tcp-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...