This article describes how to assign a “Static ip” to your local computer
If you are looking to get a “Static ip”, that is; a static ip for your whole internet connection;
What is an ip address?
An ip address is like a telephone number that any computer can use to find any other computer in a network. All networked computer have ip address. Most have a static ip, that is, they don’t change (for example Google is 74.125.45.100, and typing http://74.125.45.100/ into your browser will take you straight to Google. That is Google’s “public ip” or “external ip”, behind their NAT are probably thousands of separate machines, each with different “private” ip’s ( probably static of mixed of dynamic and static ip’s ), 192.168.1.1, 192.168.1.2..etc, we don’t see those. But some ip’s do change..
Home computers by default are set to get their private ip address dynamically from your gateway device (router), via dhcp, In other words, the router supplies a private ip address for your computer to use, temporarily ( your router is probably doing NAT), too, and needs your computer to have an ip address, so it knows where to send your data packets). However, dhcp is not an ideal setup; if there is any interruption in the computers network connection to the router (you reboot your PC, for instance), a completely new ip address may be assigned.
Home computers by default are set to get their private ip address dynamically from your gateway device (router), via dhcp, In other words, the router supplies a private ip address for your computer to use, temporarily ( your router is probably doing NAT), too, and needs your computer to have an ip address, so it knows where to send your data packets). However, dhcp is not an ideal setup; if there is any interruption in the computers network connection to the router (you reboot your PC, for instance), a completely new ip address may be assigned.
For general (beginner’s) use, dhcp is just fine, because it’s easier; generally works “out of the box”, requiring no configuration at all. But if you want to do more; run servers, p2p applications, interesting communication devices etc, you will be creating port forwarding/NAT rules on your computer, to direct incoming traffic to a particular computer (the one running the server), and if you want those rules to be effective past your next reboot, you will need to get a static ip on your system, so that the incoming data packets can still find you.
Let us start
“Private” ip addresses usually begin with 192.168.*.* and must be on the same “subnet” that the router is on, in other words, 192.168.1.*, and not 192.168.4.*. Only the last number will be different from the address of your router which by default (at least foe Voyager routers), lives at 192.168.1.1, 192.168.0.1 is also common.
** There are other private ranges, too, but most people don't need to know about those, 192.168.1.something is what most folk use, and though thousands of millions of machines in the world have 192.168.1.something as their private IP address, they don't interfere with each other because they are behind NATs and other gateways; from the outside, we only see the public IP address, aka. “External IP”.
HOWEVER, if your router uses 192.168.0.something, or 10.0.0.something, or something else from the private IP ranges.
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
then don't hesitate to use THAT instead of the 192.168.1.something addresses I use in my examples, that's what most routers use, but not all. Do check.
The best way to know what subnet your router uses, and thereby which IP to use, is to look and see what IP it has currently assigned to your computer. In Windows, it's in the Support tab of the connection's Status dialog. A netstat command will get you the same information (and more) on most platforms, perhaps netstat -n. Your router's web interface will likely have all this information, too.
If your router has USB, it has probably already grabbed 192.168.1.2 for the USB connection, so that leaves you with any number between 192.168.1.3 and 192.168.1.254 to use for your private computers to use as static IP's, one unique number per machine.
Remember to disable dhcp in your router before you start assigning static IP's
Alternatively, create a new dhcp range somewhere away from your regular static IP's, handy for guests and what-not, perhaps 192.168.1.50 - 192.168.1.99
Fortunately, assigning a static IP is very easy to achieve, and the same principle applies to every computing platform, the only real difference being where to apply the settings.
Windows
Control Panel >> Network and Internet >> Network and Sharing Center >> Change Adapter Settings >> Local Area Connection (right click) >> Properties >> TCP/IP >> Properties
Open the control panel open Network Connections, right-click the "Local Area Connection" and choose "Properties", then select "Internet Protocol (TCP/IP)" and click the "Properties" button. Check the "Use the Following IP address" checkbox and enter your desired IP address. If you use 192.168.1.98 as your IP address, the dialog will look something like this.
In most cases they will also give you IP addresses for the DNS servers you should use. Click on Use the following DNS server addresses and enter that information as well.
Enter the DNS server address as 208.67.222.222 and 208.67.220.220
Which is a clever screencap, showing you just how to get there; when you're done, okay everything to close all the dialogs; it’s smart to use 192.168.1.98 as your address, especially if you plan to use any of the ready-made script kicking around here.
And If you are behind a router, things get a little more complicated.
The first thing to realize is that the static IP address should probably be assigned to the router. That will require configuring the router, much like we configured your server above. Exactly how will vary from router to router, but the principals are the same: you'll configure the router to not get an IP address dynamically, but instead you'll enter the IP, gateway, subnet, and possibly DNS information by hand, using whatever approach your router uses for configuration.
The "trick", if you want to call it that, is telling the router to pass on requests it receives from the internet to your server. It's typically referred to as port-forwarding. Once again, depending on how your router is configured, the general idea is that you configure it to accept requests on certain "ports" and direct them to certain computers on your LAN.
The port part is fairly easy. If you want to set up a web server, then you'll know that port 80, where http requests are handled, is the port you want to forward. But to where?
Much like your direct connection to the internet, you'll need to assign your server a static IP address within your local network, so that the router knows what machine to forward the requests to. Typically a router will tell you, or let you configure, the range of IP addresses it will assign from dynamically, so you'll simply want to choose an IP address outside of that range. For example my router at home is configured to assign dynamic IPs starting at 192.168.1.100 and up. So I've elected to assign a static IP on my local area network of 192.168.1.2 (192.168.1.1 is the address of the router on the local network).
So the rest is simply a variation on what I've already covered: configure that server with the static IP you've chosen, a subnet mask of 255.255.255.0 should do, the default gateway should be the router (192.168.1.1 in my case), and quite probably the router should also be your DNS. If not, use the DNS settings that your ISP assigned you.
Now configure the router to forward port 80 traffic to the static IP address you chose, and ... there you are. Your web server, behind a router, should be visible from the internet.
Save and Apply and reboot your router..!!
No comments:
Post a Comment