1

I have written an app which will run on a server. I have little experience with network configuration and such things.

Now I have set-up the server and everything works how I want however I want 2 things

  1. set the ip of my server to a static ip
  2. ideally be able to acces the server with a url like mytestserver.test or something like that

I do have experience with command line linux and windows but never needed to do anything with networks as I usually work with embedded systems

e\ my distribution is debian on the raspberry pi

2
  • Which distribution are you using for the server? Setting up the static IP is a little different depending. And is it acceptable for the server to be accessible from that URL from only one machine or a small set, rather than a whole network or the internet?
    – Dylan
    May 17, 2014 at 23:52
  • added in the question.
    – John Smith
    May 17, 2014 at 23:54

1 Answer 1

2

Static IP

This is how to set up a static IP in Ubuntu if I recall correctly, it should also work in Debian and likely other Debian based distros:

You need to edit the network interfaces file located at /etc/network/interfaces, e.g.

nano /etc/network/interfaces

You should see a line like

iface eth0 inet dhcp

Comment this out with # and instead add:

iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1

EDIT: Explanation of network parameters

Address - Just the IP address of the server, this can be whatever you want as long as it's in the right subnet and not already used on your network

Netmask - This affects just what addresses you can use, for a home network this is almost certainly 255.255.255.0

Network - the address of the entire network, this is the first address in your subnet and will be the same first three sections as address and end with 0 on a typical home configuration

Broadcast - this one is the last address in the subnet, usually has the same first three sections as the address and ends with a 255 on a typical home network

Gateway - the address of the route, on a typical home network this is usually the second on the subnet (e.g. 192.168.0.1 or 192.168.1.1)


Alter with your own network parameters if they differ. Now, for DNS, edit /etc/resolv.conf and add a nameserver, e.g.:

nameserver 8.8.8.8

You might be able to change the nameservers in the interfaces as well, but I can't remember for sure.

After you've done this, you'll need to restart the networking service:

/etc/init.d/networking restart

Setting a Host on Your Local Machine to Access a Dev Web Address

This is the easiest way to access your dev server at an address, but it'll only work for the machines you specifically set it for. I hope that's okay. You just need to edit the /etc/hosts file. Like so:

192.168.0.10 mytestserver.test

Replace the IP address with the one for your server if different.

If you're on Windows the hosts file is at C:\windows\system32\drivers\etc. I think the syntax is the same.

4
  • thank you, address is obvious but what does the rest mean and how can I find out what I have to set it too?
    – John Smith
    May 18, 2014 at 0:23
  • I added a quick explanation of the network parameters. If you can tell me the address of your router or the server or really any other device on your network, and you're using a typical home or office network, I can probably tell you what the rest are likely to be.
    – Dylan
    May 18, 2014 at 0:31
  • its a server at my work on a shielded network so I cant really acces it right now. typical adress range is 192.168.x.y the standard IP I got assigned from dhcp was 192.168.10.147 with the server
    – John Smith
    May 18, 2014 at 0:50
  • Unless it's always 192.168.10.x that does complicate things a bit. In that case, my guess is that the values are as follows: Address: 192.168.10.147 (if you can find one that's off their DHCP that might be good, but don't worry about it too much) Netmask: 255.255.0.0 Network: 192.168.0.0 Broadcast: 192.168.255.255 Gateway: 192.168.0.1 ...though technically it could be quite a lot of other things, since it sounds like they've already gone to the trouble of expanding the default subnet or just setting one up manually.
    – Dylan
    May 18, 2014 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .