How to connecte local network web server with my global ip address from behind nat












0















When I connect my web server from the internet, I can connect to my webserver with other global IP address.



but when I connect from Desktop PC(192.168.0.3) to Web server, web server appends "192.168.0.1 ..." to logs despite I'd like to connect with my global IP address(1.x.2.3).



Please teach me how to connect local network web server with my global ip address from behind nat :)



Thank you for reading my posts.



# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
1.x.3.4 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp3s0




# ifconfig
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1454
inet 1.x.3.4 netmask 255.255.255.255 destination 1.x.y.z
ppp txqueuelen 3 (Point-to-Point Protocol)




iptables --table filter --flush
iptables --table nat --flush
iptables -X
iptables --policy INPUT DROP
iptables -t filter -A OUTPUT -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables --table filter --append INPUT --source 192.168.0.0/24 --protocol all -j ACCEPT
iptables --table nat --append PREROUTING --source 192.168.0.0/24 --in-interface enp3s0 --protocol udp --dport 53 --jump DNAT --to-destination {my ISP DNS IP address}
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d 1.x.2.3 --dport 80 -j DNAT --to-destination 192.168.0.2:80
iptables --table nat --append PREROUTING --source 192.168.0.0/24 -d 1.x.3.4 --in-interface enp3s0 --protocol tcp --dport 80 --jump DNAT --to-destination 192.168.0.2:80
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface enp3s0 --jump MASQUERADE
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface ppp0 --jump SNAT --to-source 1.x.3.4




My network diagram.
enter image description here










share|improve this question























  • You may not be able to. Google hairpin NAT

    – davidgo
    Jan 14 at 9:03
















0















When I connect my web server from the internet, I can connect to my webserver with other global IP address.



but when I connect from Desktop PC(192.168.0.3) to Web server, web server appends "192.168.0.1 ..." to logs despite I'd like to connect with my global IP address(1.x.2.3).



Please teach me how to connect local network web server with my global ip address from behind nat :)



Thank you for reading my posts.



# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
1.x.3.4 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp3s0




# ifconfig
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1454
inet 1.x.3.4 netmask 255.255.255.255 destination 1.x.y.z
ppp txqueuelen 3 (Point-to-Point Protocol)




iptables --table filter --flush
iptables --table nat --flush
iptables -X
iptables --policy INPUT DROP
iptables -t filter -A OUTPUT -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables --table filter --append INPUT --source 192.168.0.0/24 --protocol all -j ACCEPT
iptables --table nat --append PREROUTING --source 192.168.0.0/24 --in-interface enp3s0 --protocol udp --dport 53 --jump DNAT --to-destination {my ISP DNS IP address}
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d 1.x.2.3 --dport 80 -j DNAT --to-destination 192.168.0.2:80
iptables --table nat --append PREROUTING --source 192.168.0.0/24 -d 1.x.3.4 --in-interface enp3s0 --protocol tcp --dport 80 --jump DNAT --to-destination 192.168.0.2:80
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface enp3s0 --jump MASQUERADE
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface ppp0 --jump SNAT --to-source 1.x.3.4




My network diagram.
enter image description here










share|improve this question























  • You may not be able to. Google hairpin NAT

    – davidgo
    Jan 14 at 9:03














0












0








0








When I connect my web server from the internet, I can connect to my webserver with other global IP address.



but when I connect from Desktop PC(192.168.0.3) to Web server, web server appends "192.168.0.1 ..." to logs despite I'd like to connect with my global IP address(1.x.2.3).



Please teach me how to connect local network web server with my global ip address from behind nat :)



Thank you for reading my posts.



# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
1.x.3.4 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp3s0




# ifconfig
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1454
inet 1.x.3.4 netmask 255.255.255.255 destination 1.x.y.z
ppp txqueuelen 3 (Point-to-Point Protocol)




iptables --table filter --flush
iptables --table nat --flush
iptables -X
iptables --policy INPUT DROP
iptables -t filter -A OUTPUT -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables --table filter --append INPUT --source 192.168.0.0/24 --protocol all -j ACCEPT
iptables --table nat --append PREROUTING --source 192.168.0.0/24 --in-interface enp3s0 --protocol udp --dport 53 --jump DNAT --to-destination {my ISP DNS IP address}
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d 1.x.2.3 --dport 80 -j DNAT --to-destination 192.168.0.2:80
iptables --table nat --append PREROUTING --source 192.168.0.0/24 -d 1.x.3.4 --in-interface enp3s0 --protocol tcp --dport 80 --jump DNAT --to-destination 192.168.0.2:80
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface enp3s0 --jump MASQUERADE
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface ppp0 --jump SNAT --to-source 1.x.3.4




My network diagram.
enter image description here










share|improve this question














When I connect my web server from the internet, I can connect to my webserver with other global IP address.



but when I connect from Desktop PC(192.168.0.3) to Web server, web server appends "192.168.0.1 ..." to logs despite I'd like to connect with my global IP address(1.x.2.3).



Please teach me how to connect local network web server with my global ip address from behind nat :)



Thank you for reading my posts.



# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
1.x.3.4 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp3s0




# ifconfig
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1454
inet 1.x.3.4 netmask 255.255.255.255 destination 1.x.y.z
ppp txqueuelen 3 (Point-to-Point Protocol)




iptables --table filter --flush
iptables --table nat --flush
iptables -X
iptables --policy INPUT DROP
iptables -t filter -A OUTPUT -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables --table filter --append INPUT --source 192.168.0.0/24 --protocol all -j ACCEPT
iptables --table nat --append PREROUTING --source 192.168.0.0/24 --in-interface enp3s0 --protocol udp --dport 53 --jump DNAT --to-destination {my ISP DNS IP address}
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d 1.x.2.3 --dport 80 -j DNAT --to-destination 192.168.0.2:80
iptables --table nat --append PREROUTING --source 192.168.0.0/24 -d 1.x.3.4 --in-interface enp3s0 --protocol tcp --dport 80 --jump DNAT --to-destination 192.168.0.2:80
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface enp3s0 --jump MASQUERADE
iptables --table nat --append POSTROUTING --source 192.168.0.0/24 --out-interface ppp0 --jump SNAT --to-source 1.x.3.4




My network diagram.
enter image description here







router iptables nat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 14 at 8:15









mistdrillmistdrill

1




1













  • You may not be able to. Google hairpin NAT

    – davidgo
    Jan 14 at 9:03



















  • You may not be able to. Google hairpin NAT

    – davidgo
    Jan 14 at 9:03

















You may not be able to. Google hairpin NAT

– davidgo
Jan 14 at 9:03





You may not be able to. Google hairpin NAT

– davidgo
Jan 14 at 9:03










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%2f1394011%2fhow-to-connecte-local-network-web-server-with-my-global-ip-address-from-behind-n%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%2f1394011%2fhow-to-connecte-local-network-web-server-with-my-global-ip-address-from-behind-n%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

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy