• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

Setting up a static ip on ubuntu

I am fairly new to ubuntu and this is the first time I have had a bash installing a server.  I managed to install apache, mysql, phpadmin etc. successfully and I get the lovely "it works!" message when I go to localhost through my web browser in gnome.  

bAt the momment though the system is set to dhcp and I am aware I need it to have a static lan ip address so I can forward to it from my router which is using "dyndns" to link my dynamic ip to a domain name.

So...How do I set ubuntu to use a static IP instead of dhcp?  And what should I set my "IP address", "Subnet mask" and "Gateway address" to?

(This has ended up being a bit of a long question, ut i being new on ubuntu i wasn't sure what information would be needed, so I put in everything i could think of)
0
Susurrus
Asked:
Susurrus
  • 4
  • 3
2 Solutions
 
torimarCommented:
If this is a private network, you may not even have to reconfigure your settings. In my router, under Network > Devices and Users I'm able to edit a connected device and have it given the same IP whenever connecting.

If your router will not do this, here are some HowTos for the reconfiguration:
http://www.howtogeek.com/howto/ubuntu/change-ubuntu-server-from-dhcp-to-a-static-ip-address/
http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html

As to your questions:
Use the IP address, Subnet and Broadcast currently in use. You will see them when issuing the "ifconfig" command.
Your Gateway will be the network IP address of your router. It will also most likely be set as nameserver in your /etc/resolv.conf, so leave this file and nameserver settings as they are.
Check your router's interface for more information about your network settings if needed, and adopt defaults from the tutorials in cases of doubt.

Good luck.
0
 
torimarCommented:
ps:
I just saw that the second HowTo goes into a lot of things that are not needed for a simple DHCP -> Static reconfiguration.
Ignore them, and follow the first one compared with this:
http://www.ubuntugeek.com/change-ubuntu-system-from-dhcp-to-a-static-ip-address.html
0
 
SusurrusAuthor Commented:
When I print ifconfig i get this:


eth0      Link encap:Ethernet  HWaddr 00:11:d8:0c:aa:67  
          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::211:d8ff:fe0c:aa67/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:46038 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27902 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:59725040 (56.9 MB)  TX bytes:2666409 (2.5 MB)
          Interrupt:16

eth1      Link encap:Ethernet  HWaddr 00:0a:cd:0c:15:70  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 Base address:0xb000

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1854 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1854 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100777 (98.4 KB)  TX bytes:100777 (98.4 KB)


My connection is on eth0 but I am not sure which line contains the information I need
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
EggpatchCommented:
edit your

/etc/network/interfaces

iface eth0 inet static

address (machine ip)
netmask (machine ip mask)
gateway (your gateway ip)
broadcast (your broadcat ip)
network (your network ip)

example

address 192.168.0.111
netmask 255.255.255.0
gateway 192.168.0.1
broadcast 192.168.0.255
network 192.168.0.0
0
 
torimarCommented:
"inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0"

inet addr: your IP
Bcast: your broadcast IP
Mask: your netmask
0
 
torimarCommented:
For your Network IP, replace the "255" in your Broadcast IP by a "0", i.e.:
192.168.0.0
0
 
SusurrusAuthor Commented:
thanks!  I got there in the end.  This is proving to bee a steep learning curve
0
 
SusurrusAuthor Commented:
Sorted me out completey.  Thanks!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now