Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How can i create public facing webserver out of laptop located in any LAN?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How can i create public facing webserver out of laptop located in any LAN?

Hello,

when i connect Linux (LAMP) notebook to the LAN that has internet access, how can this notebook be accessible to the world and people can load website mywebsite.com hosted on it without configuring routers in the LAN?

I know there are "dynamic DNS providers" who can give a static identity to the computer, but not sure if i can use it for this purpose, i certainly prefer doing this DNS service by myself. Like having VPS with public static IPv4 and it will serve as some proxy or DNS service for my laptop that i can connect to any LAN across the internet while on the laptop are all web server data. Again, assuming i will not have access to the routers that controlling the LANs i will use.

Question is how to do it?

Thank you for the input

Comments

  • Just use routing to port 80 to your laptop local adress and change the router port (usually it use port 80)

  • netomxnetomx Moderator, Veteran
    edited August 2016

    Vpn to your vps, and there forward port 80 to the internal ip of the vpn client

  • change the router port

    i said "i will not have access to the routers that controlling the LANs i will use"

    @netomx

    It sounds good, i know how setup openvpn and connect to it using ovpn or such file on the client, but how to forward that port? Please can you give me some google phrasse so i can find details how to do it on the openvpn server/client?

  • netomxnetomx Moderator, Veteran

    Google iptables forward port to another ip

  • postcdpostcd Member
    edited August 2016

    @netomx said:

    Google iptables forward port to another ip

    thx, i can find this, but what will be that "another IP" while i think my laptop will not have any public IP in the LAN. Only public IP is the one "controlled by router" which i do not have access to..
    // update, there is something: https://unix.stackexchange.com/questions/55791/port-forward-to-vpn-client

    I can try to mess with port forwarding mentioned, but can anyone advice more in detail? I installed Virtualbox on my laptop and on virtuaised CentOS is running webserver. After i install OpenVPN client and execute 3 port forwarding commands adviced on above stackkexchange.com link (execued on my VPS proxy server), then after anyone enter IPOfMyVPS:80, it will show my webserver default page served from my Laptop located anywhere?

  • @postcd said:
    thx, i can find this, but what will be that "another IP" while i think my laptop will not have any public IP in the LAN. Only public IP is the one "controlled by router" which i do not have access to..

    You have to forward port 80 from your VPS public ip address to your internal openVPN ip-adress of your laptop. You can either assign them by DHCP or static, which is more practical in your case.

    Thanked by 1postcd
  • edited August 2016

    postcd, netomx try to say something like this :

    Connec your Laptop to the vps, using the vpn. After it's connected, it will get the private ip from the vpn, such 10.8.0.2, or something.

    Next, add the iptables in the vps , for example :
    iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.8.0.2

    That iptables rule will be working, if the vps not running any web server on port 80. And set the domain name to the vps ipv4 address, so whenever someone visited the domain, they will be opening the vps ip, and redirected to the Laptop webserver

    Thanked by 3FrankZ netomx postcd
  • What @ErawanArifNugroho said plus one little addition to iptables

    iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.8.0.2     
    iptables -t nat -A POSTROUTING -s 10.8.0.2 -j SNAT  --to [vps-ip]

    replace [vps-ip] with your vps ipv4 number

    Thanked by 1postcd
  • @netomx said:
    Vpn to your vps, and there forward port 80 to the internal ip of the vpn client

    Or ironically enough, host your site on that VPS instead and not even worry about this issue.

    Thanked by 2netomx postcd
  • netomxnetomx Moderator, Veteran

    @Pwner said:

    @netomx said:
    Vpn to your vps, and there forward port 80 to the internal ip of the vpn client

    Or ironically enough, host your site on that VPS instead and not even worry about this issue.

    Ikr? Hahaha

  • netomxnetomx Moderator, Veteran

    @ErawanArifNugroho said:
    postcd, netomx try to say something like this :

    Connec your Laptop to the vps, using the vpn. After it's connected, it will get the private ip from the vpn, such 10.8.0.2, or something.

    Next, add the iptables in the vps , for example :
    iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.8.0.2

    That iptables rule will be working, if the vps not running any web server on port 80. And set the domain name to the vps ipv4 address, so whenever someone visited the domain, they will be opening the vps ip, and redirected to the Laptop webserver

    Exactly

    Thanked by 1postcd
  • note you can use an SSH tunnel and just forward port 80 rather than needing to use a full vpn

  • "no ip" use to do the same, if I remember it correctly! have not seen it in yrs though.

Sign In or Register to comment.