Results 1 to 10 of 18

Thread: Setting up Static IP Address - 12.04LTS

Hybrid View

  1. #1
    Join Date
    May 2012
    Beans
    40

    Setting up Static IP Address - 12.04LTS

    Hey All,

    I've attempted to set up a static ip address for my home computer (Ubuntu 12.04LTS), and have followed a few online instructions to no avail. I've managed to reverse what I did, but I'd still like to know the in's and out's of setting up ip addresses.

    First of all, what is a static ip address and why does it offer better performance? Is it at all bad for security? Basically, I've heard that I should set up a static ip address and I'm not entirely sure why.

    My first crack at this was to run the terminal command:
    Code:
    ifconfig
    This shows me a whole bunch of stuff that I don't really know how to interpret. Here's the output:

    Code:
    eth0      Link encap:Ethernet  HWaddr c8:60:00:e3:6b:d0  
              inet addr:192.168.1.108  Bcast:192.168.1.255 Mask:255.255.255.0
              inet6 addr: fe80::ca60:ff:fee3:6bd0/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:2214 errors:0 dropped:0 overruns:0 frame:0
              TX packets:2351 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:1669345 (1.6 MB)  TX bytes:301602 (301.6 KB)
              Interrupt:20 Memory:f7f00000-f7f20000 
    
    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:764 errors:0 dropped:0 overruns:0 frame:0
              TX packets:764 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:74443 (74.4 KB)  TX bytes:74443 (74.4 KB)
    
    wlan0     Link encap:Ethernet  HWaddr 94:db:c9:4b:87:6d  
              inet addr:192.168.1.107  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::96db:c9ff:fe4b:876d/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1399 errors:0 dropped:0 overruns:0 frame:0
              TX packets:169 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:410867 (410.8 KB)  TX bytes:33267 (33.2 KB)
    What I attempted next was to change the "managed=false" to "managed=true" in the file: /etc/NetworkManager/NetworkManager.conf

    Then I went into the file: /etc/network/interfaces

    Which originally looked like this:
    Code:
    auto lo
    iface lo inet loopback
    And changed it to this:
    Code:
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
    address 192.168.1.108
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    I then edited my connections, and entered in these addresses, and made sure that under IPv4 the method was 'Manual'.

    Can anyone see where I messed up?

    Thank you for your help!!
    Last edited by AustenG; May 24th, 2012 at 03:59 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    26,047
    Distro
    Ubuntu Development Release

    Re: Setting up Static IP Address - 12.04LTS

    I know of no compelling reason that an ordinary home computer needs a static IP. That said, I have two computers in my home on which I've set up static IPs. My wife's computer runs Ubuntu 12.04. As you might guess, I'm the in-house support. I think it's fun to log on to her computer with ssh and do administrative tasks.

    I have a printer attached to a computer and all the other computers in the house use it. It's much easier to set up with a static IP rather than samba, bind, etc. Beyond that, and perhaps a home server, I don't believe there is any speed or stability reason to use static IP addresses.

    You've made a few mistakes. First, you have IP addresses for both wired and wireless. If you have the option for wired, use it in preference to wireless. It's faster and more secure. Flip the wireless switch or key combination to OFF.

    Second, as you know, there is a provision in Network Manager to set up static IP addresses. There is no need and possibly some complication to mix NM and /etc/network/interfaces. I suggest the NM method but not both. Of course, you could remove NM altogether and use manual methods entirely.

    Next, you've picked an IP address that appears to be within the range used in the DHCP server in the router. You want one outside the range so there is no collision. For example, I've set my router to allow ten addresses by DHCP from 192.168.1.3 to x.12. All my static IPs are in the rage of 192.168.1.100 and up.

    Also, you haven't specified DNS nameservers. When a computer is given an IP address by DHCP, the router supplies DNS nameserver addresses. If you set static IPs, you are assumed to be in charge of such details.

    If you want to try again, I'd suggest:
    Code:
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
    address 192.168.1.178
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 192.168.1.1
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, B.Sc., M.Sc., M.A., Ph.D., Sc.D.

  3. #3
    Join Date
    May 2012
    Beans
    40

    Re: Setting up Static IP Address - 12.04LTS

    Thanks for the response!

    Quote Originally Posted by chili555 View Post
    You've made a few mistakes. First, you have IP addresses for both wired and wireless. If you have the option for wired, use it in preference to wireless. It's faster and more secure. Flip the wireless switch or key combination to OFF.
    What do you mean by flip the wireless switch or key combination? I'd like to default to wired connection whenever possible, but I'd like the option to access wireless as well (I have a few machines/devices which could been hooked up and I'd like the freedom to pick and choose).

    Quote Originally Posted by chili555 View Post
    Second, as you know, there is a provision in Network Manager to set up static IP addresses. There is no need and possibly some complication to mix NM and /etc/network/interfaces. I suggest the NM method but not both. Of course, you could remove NM altogether and use manual methods entirely.
    Is NM accessed by the file in /etc/NetworkManager/NetworkManager.conf ? Also, why do you suggest the NM solution over the other method?

    Quote Originally Posted by chili555 View Post
    Also, you haven't specified DNS nameservers. When a computer is given an IP address by DHCP, the router supplies DNS nameserver addresses. If you set static IPs, you are assumed to be in charge of such details.
    So all of this is to ensure that my router knows which IP address to give to which devices, is this correct? For things like screen sharing and ssh, how do I ensure that computers outside my home network will know where to find my network? I've heard things about NO-IP, but when I took a look at it it mentioned something about having to update my address every 30 days...


    Quote Originally Posted by chili555 View Post
    If you want to try again, I'd suggest:
    Code:
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
    address 192.168.1.178
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 192.168.1.1

    ^^ This totally works now! I still don't quite understand the rules of how IP addresses are distributed to hardware on a network, but I'm marking this solved. Just to be perfectly clear about what I did: I literally copied this into my /etc/network/interfaces file. Was it just a coincidence that this worked? I understand in principle what netmask is saying. It allows me to set the number of possible IP addresses my router is allowed to give out, right? But, gateway and dns-nameservers are still a bit of a mystery to me. It seems odd that this exact same setup works for me, too. Also, what happened to broadcast?

    Sorry about all of the questions - I'm *completely* new to this whole network thing - when you run Windows and Mac these things are totally invisible most of the time (not that you can't go in and change things if you want to). It's funny how reliant we are on software, and how pissed off people get when it doesn't work in an intuitive, hassle-free way. I really like figuring this stuff out, even if it's a bit frustrating/overwhelming at times (but this is all off topic).

  4. #4
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    26,047
    Distro
    Ubuntu Development Release

    Re: Setting up Static IP Address - 12.04LTS

    What do you mean by flip the wireless switch or key combination? I'd like to default to wired connection whenever possible, but I'd like the option to access wireless as well
    Pardon me if I was incorrect, but your readings suggest this is a laptop. Laptops usually have a switch or key combination to enable or disable wireless. It is desirable not only for power saving but also a requirement in some countries to comply with flying rules; the wireless radio must be able to be affirmatively switched off.

    Network Manager is supposed to do the job for us; that is, use wired if it's available and wireless if wired isn't available. Like many things computer, it is just a bit imperfect as you saw:
    eth0 Link encap:Ethernet HWaddr c8:60:00:e3:6b:d0
    inet addr:192.168.1.108 Bcast:192.168.1.255 Mask:255.255.255.0
    inet6 addr: fe80::ca60:ff:fee3:6bd0/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    <snip>

    wlan0 Link encap:Ethernet HWaddr 94:db:c9:4b:87:6d
    inet addr:192.168.1.107 Bcast:192.168.1.255 Mask:255.255.255.0
    inet6 addr: fe80::96db:c9ff:fe4b:876d/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    My point is that if you can help things along by switching the wireless off by the switch, NM will work correctly.
    Is NM accessed by the file in /etc/NetworkManager/NetworkManager.conf ? Also, why do you suggest the NM solution over the other method?
    The settings are accessed by clicking the NM icon at the top. Where you see your networks and connections, at the bottom, you'll see Edit Connections. That's where you can add a static IP address, DNS nameservers, etc. Please see attached. I suggest the NM method simply because it's easier to access and understand in our increasingly point-and-click world. Since you have it working as is now, I'd leave it as is.
    So all of this is to ensure that my router knows which IP address to give to which devices, is this correct?
    Correct.
    For things like screen sharing and ssh, how do I ensure that computers outside my home network will know where to find my network?
    I'm sorry, that's outside my area of knowledge; they only let me play with the simple stuff here. When you get ready to do those things, I suggest a new specific thread.
    I still don't quite understand the rules of how IP addresses are distributed to hardware on a network, but I'm marking this solved. Just to be perfectly clear about what I did: I literally copied this into my /etc/network/interfaces file. Was it just a coincidence that this worked? I understand in principle what netmask is saying. It allows me to set the number of possible IP addresses my router is allowed to give out, right? But, gateway and dns-nameservers are still a bit of a mystery to me. It seems odd that this exact same setup works for me, too. Also, what happened to broadcast?
    Well, my years of experience and 13,000 posts suggest it wasn't a coincidence. You posted your malformed interfaces file above and I could see certain details about it which I used to build a file that works.

    Your router, using the address of 192.168.1.1, is an ordinary consumer-grade router. They do a fine job. By definition, these devices have available 252 addresses. They are usually set to allow 50 addresses by DHCP; that means, roughly, the router will take care of all the details for us. That's perfect for the ordinary user. The router and the computer will figure out all the details in the background.

    However, that leaves another 202 addresses to be used by those of us who are willing and knowledgeable enough to supply our own details.

    The most often missed detail by those who venture into static IPs is DNS nameservers. The internet doesn't know who or what www.google.com is. It works by numbers, not names. So, how can we translate www.google.com into 173.194.73.147? There are sites that do nothing but that; look up a name, translate it to a number and pass it on. Without that translation, your internet traffic goes nowhere.

    One option is your router, we know it has the information, it's providing DNS nameservers for all the other devices on your network. However, Google themselves host a very fast reliable nameserver: 8.8.8.8. So I suggested you use it as a primary DNS and the router as a fallback:
    dns-nameservers 8.8.8.8 192.168.1.1
    As for broadcast, in a private, home network, it works perfectly fine without it. I'm a minimalist; the fewer details I must fill in, the fewer that can go wrong!
    Attached Images Attached Images
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, B.Sc., M.Sc., M.A., Ph.D., Sc.D.

  5. #5
    Join Date
    May 2012
    Beans
    40

    Re: Setting up Static IP Address - 12.04LTS

    Thanks a lot for the information!

  6. #6
    Join Date
    Dec 2009
    Location
    Taiwan
    Beans
    3
    Distro
    Kubuntu

    Re: Setting up Static IP Address - 12.04LTS

    I am new to the basics of Ubuntu I want to know if I am configured properly because every time I try to go to my Yahoo account I always get a "connection was reset" message.

    Here is what my configuration looks like:
    ifconfig
    eth0 Link encap:Ethernet HWaddr 00:1f:d0:21:1b:66
    inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
    inet6 addr: fe80::21f:d0ff:fe21:1b66/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:167075 errors:0 dropped:0 overruns:0 frame:0
    TX packets:107339 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:244055704 (244.0 MB) TX bytes:8499422 (8.4 MB)
    Interrupt:42 Base address:0xc000

    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:20 errors:0 dropped:0 overruns:0 frame:0
    TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1200 (1.2 KB) TX bytes:1200 (1.2 KB)

    I don't understand what this means.

  7. #7
    Join Date
    Oct 2013
    Beans
    2

    Smile Re: Setting up Static IP Address - 12.04LTS

    Quote Originally Posted by chili555 View Post
    I'd suggest:
    Code:
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
    address 192.168.1.178
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 192.168.1.1
    Thanks this really helped and with the obvious slight change of addresses to suit my range 192.168.10.xxx I got my Ubuntu Server 10.04LTS working.

    Craig....

  8. #8
    Join Date
    May 2008
    Location
    Saint Louis
    Beans
    57
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Setting up Static IP Address - 12.04LTS

    Quote Originally Posted by chili555 View Post
    I know of no compelling reason that an ordinary home computer needs a static IP. That said, I have two computers in my home on which I've set up static IPs. My wife's computer runs Ubuntu 12.04. As you might guess, I'm the in-house support. I think it's fun to log on to her computer with ssh and do administrative tasks.

    I have a printer attached to a computer and all the other computers in the house use it. It's much easier to set up with a static IP rather than samba, bind, etc. Beyond that, and perhaps a home server, I don't believe there is any speed or stability reason to use static IP addresses.

    You've made a few mistakes. First, you have IP addresses for both wired and wireless. If you have the option for wired, use it in preference to wireless. It's faster and more secure. Flip the wireless switch or key combination to OFF.

    Second, as you know, there is a provision in Network Manager to set up static IP addresses. There is no need and possibly some complication to mix NM and /etc/network/interfaces. I suggest the NM method but not both. Of course, you could remove NM altogether and use manual methods entirely.

    Next, you've picked an IP address that appears to be within the range used in the DHCP server in the router. You want one outside the range so there is no collision. For example, I've set my router to allow ten addresses by DHCP from 192.168.1.3 to x.12. All my static IPs are in the rage of 192.168.1.100 and up.

    Also, you haven't specified DNS nameservers. When a computer is given an IP address by DHCP, the router supplies DNS nameserver addresses. If you set static IPs, you are assumed to be in charge of such details.

    If you want to try again, I'd suggest:
    Code:
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
    address 192.168.1.178
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 192.168.1.1
    thank you kindly for this post. ubuntu server 12.04.4

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •