If you want to host a website that others can see, you have to have static IP address. By default computer will request a dynamic IP address which is issued by your router as required. That means your IP address may change in future which would make it hard to connect to the webserver. Instead we set it to something that doesn't change. For example if you have a dynamic IP your servers address could change in every day and no one wouldn't know where it is. First find out what DHCP address has been allocated by using the ifconfig command.
$ ifconfig
under eth"number" eth0 for example, look for line which says something like: inet addr:192.168.1.110. This is saying that the ethernet port 0 has an IP address of 192.168.1.110. This is your computers address in the home network. Notice that every computer needs its own unique IP. If two computers has the same IP address internet doesn't either work or it works randomly. You will also need to find out what address your router is, using the route command
$ route
Under "Default Gateway" you find an IP address and that is where all traffic is sent via.
Now you need to check on what address range is being issued by the router. I suggest to check Portforward.com it has a list for many routers and programs which port they should use. And how to apply ports. I have used 3 different routers and have always found instructions for my router and specific programs.
Leave that for now. To change to static IP address in RaspberryPi
$ cd /etc/network
$ sudo nano interfaces
check it has a nameserver enty pointing to your default gateway. Set the address to unique address on your home network. Look the images from Penguintutor. Reboot is suggested after IP change just to make sure everything is ok.
$ sudo reboot
After logging in check using $ ifconfig to confirm that you have a static ip address.
Now back to the router thing. You should locate your router by pointing your browser to it. Mine example works with 192.168.1.1. You should find something that says "applications" or "virtual server". Again look for portforward.com
You should select right ports for your program and then set the computer which can use the ports. After that your server is visible on the public network.
Ei kommentteja:
Lähetä kommentti