Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Login / Signup
Ads by Google
Changing this setting without a GUI will require some text editing, but that’s classic linux,
right?
Daily Email Updates
Let’s open up the /etc/network/interfaces file. I’m going to use vi, but you can choose a You can get our how-to articles in your inbox
different editor each day for free. Just enter your email below:
For the primary interface, which is usually eth0, you will see these lines:
MEET THE AUTHOR
As you can see, it’s using DHCP right now. We are going to change dhcp to static, and then
there are a number of options that should be added below it. Obviously you’d customize
this to your network. Recent Articles
Desktop Fun: Resident Evil Wallpaper Collection
auto eth0
Android Style Icons Pack for Your Computer
iface eth0 inet static
address 192.168.1.100 Clone Troopers: The Training Center [Video]
netmask 255.255.255.0
Restore the Windows Boot Loader After an Ubuntu
network 192.168.1.0 Update
broadcast 192.168.1.255
gateway 192.168.1.1 Snowy Evening with Moon Shining Wallpaper
Related Articles
Now we’ll need to add in the DNS settings by editing the resolv.conf file:
Change Ubuntu Desktop from DHCP to a Static IP
Address
sudo vi /etc/resolv.conf How to Assign a Static IP to an Ubuntu 10.04
Desktop Computer
You need to also remove the dhcp client for this to stick (thanks to Peter for noticing). You How to Assign a Static IP Address in XP, Vista, or
might need to remove dhcp-client3 instead. Windows 7
Updated Thanks to Nickname007 in the comments for noting that I forgot the DNS entries
in the guide.
Ads by Google
Change Ubuntu Desktop from DHCP to a Static Android Style Icons Pack for Your Computer
IP Address Clone Troopers: The Training Center [Video]
How to Assign a Static IP to an Ubuntu 10.04 Snowy Evening with Moon Shining Wallpaper
Desktop Computer
The Commuter – Short HD Movie Filmed Using
Change your Network Card MAC Address on a Nokia N8 Smartphone [Video]
Ubuntu
Pinta is a Cross-Platform Paint.NET Clone
Beginner: How To Set Up A Static IP in Mac
OS X Mirror’s Edge Theme for Windows 7
How to Assign a Static IP Address in XP, Vista,
or Windows 7
Comments (62)
And what about configuring your router to force that server to recieve that IP address
through dhclient?
Why does no body write a complete guide for this? Follow these steps and all sorts of
things will break such as web-surfing, updates, mail – basically anything that required
name resolution. This is half of what you need to do. Here is the rest.
1. With a dynamic ip address, at the console as root type: ifconfig /all. Write down the IP
address for your name server.
2. Follow this guys steps.
3. As root, type: vim /etc/resolv.conf. On the line ‘name server xxx.xxx.xxx.xxx’ replace the
x with the IP of your name server. Restart networking. Ping http://www.google.com. If you
get a responce, name resolution is working(unless of course if google is in your hosts file).
Good luck people, enjoy.
@NIckname007
Thanks for noticing the missing information! I’ve updated the guide with your comments.
When I follow above directions network will not restart…error ifdown: couldn’t read
interfaces file “/etc/network/interfaces” /etc/network/interfaces:2: misplaced option. Same
for ifup. Even if change back to original configuration, get same error.
Changes are:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
Should have mentioned further….cannot run ifconfig – same error. Did verify that
/etc/resolv.conf does already point to correct nameservers….
Seems to be some other conf file that gets dynamically changed when making the above
changes and needs to be corrected, but don’t know where to begin. Any help is greatly
appreciated.
HI Charles,
I have just met and solved this problem myself. It had me tearing my hair out and, as
usual, it was something small I had overlooked. The error message is telling you that there
is a problem with the syntax of the interfaces file. In my case there was a comment mark
(#) missing from the second line of the file, right at the top where it gives a bit of info about
what the file does – I was concentrating so hard on the meat of the file I didn’t think to look
up there for quite a while. Hope this helps.
I have been searching for this exact information for hours! I wish google had psychic
powers (coming in 2009)
I found what the problem was for me.. my editor for the TOP commented line of the
‘interfaces’ file had for some reason gone onto the next line -
e.g.
# This file describes the network interfaces available on your
system and how to activate them. For more information, see interfaces(5).
IT SHOULD HAVE BEEN -
# This file describes the network interfaces available on your system and how to activate
them. For more information, see interfaces(5).
I JUST DELETED THE CARRAGE RETURN AND IT WORKED A TREAT!
When i type in
sudo vi /etc/network/interfaces
all i get is a blank screen with the following character
~
~
~
~
~
Can anyone help? Im a noob when it comes to this.
Any Help would be appreciated.
when i type in
sudo vi /etc/resolv.conf
i get the same screen mentioned in the post above by Jose. should i just type in my
nameserver xxx.xxx whatnot?
I experienced that it is necessary to remove the dhcp client package in order to prevent
overwriting of the resolv.conf file. (dhcp-client or dhcp3-client). Use Aptitude to remove
these packages if they are installed. Then the modification to resolv.conf will last.
Good luck.
Works great…. Until my ubuntu server decides to go out and ask my router for a dhcp
lease anyways. I still see that “dhclient3″ is still running and listening to eth0. how do I fix
that? It’s really annoying when every morning my ip address changes from x.x.x.50 to
x.x.x.102 and all of my port forwardings break and I can’t remotely access my box until I
go in and do an /etc/init.d/networking restart. please help!
this article was really helpful for a newbie like me.. thanks a lot the responser
This How-To is very helpful. I did need the follow-up comments from Peter Zandbergen
and Sheldon Cooper to keep the server from reverting to DHCP. To remove the dhcp
client and kill the process:
.
$ sudo apt-get remove dhcp3-client
…
$ ps aux | grep dhcp
dhcp 4294 0.0 0.0 14096 680 ? S
yes, for some reason pico wrapped the top comment line and then saved it…so you get
the misplaced option error really quite annoying, I’m glad someone else figured it out and
saved me several hours of annoyance!
Thanks! Reading a clear walkthrough makes this stuff a lot easier. Keep writing, i’ll keep
reading.
Good stuff.
On my machine the package is called dhcp3-client, not dhcp-client3.
Cheers, worked a treat, had a problem with machine dropping ip address with dhcp, this
soon sorted it out
Yeh about the router. Wouldn’t you still have to config it a static ip too. I have cable and its
set to dynamic. If so is there any way I can find my dns server name (ie
xxxx.xxxx.xxxx.xxxx) without contacting my isp provider.
HI all……….I tried the as given below but error comes every time same…
After vi/etc/network/interfaces I made changes like
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
After I restart the network
sudo /etc/init.d/networking restart
I got the following error msg
root@excel:~# sudo /etc/init.d/networking restart
* Reconfiguring network interfaces… /etc/network/interfaces:1: misplaced option
ifdown: couldn’t read interfaces file “/etc/network/interfaces”
/etc/network/interfaces:1: misplaced option
ifup: couldn’t read interfaces file “/etc/network/interfaces”
[fail]
I tried this
ls -lah /etc/network/interfaces
Iget
root@excel:~# ls -lah /etc/network/interfaces
-rwxrw-rw- 1 root root 202 2008-07-30 12:05 /etc/network/interfaces
Then I tried this one
Thanks for the article. It’s guys like you that make Linux bearable.
I had the misplaced option file problem as well. Turns out, at the very bottom of my
interfaces file (like 20 returns down) it had repeated the options for eth0, which must have
been confusing the OS. so make sure there’s nothing hidden at the bottom of your file.
I have a proxy server with two interfaces. The Internet interface gets its IP via DHCP from
a DSL modem on a 10.0.0.0 network, the other is static 192.168.1.0 LAN network which is
setup as this article.
Therefore I cannot get rid of the DHCP client.
Thanks alott !
In Ubuntu server 9 (and perhaps earlier versions) the dhcp client package is called dhcp3-
client and not dhcp-client3 as it is stated in the step-by-step guide.
Thanks for the guide though.
If you still have to use dhcp, then the client can be started with an option so as not to
overwrite /etc/resolv.conf (and maybe some others). Errr, I wish I could be more specific
but I just uninstalled dhcp . Thanks for the guide.
absolutely exelent!!!!!
ur info is exactly useful
thanks a lot and more power!!!!!!!
i really love it!!!!!!!!
u wrote:
(You can do ifconfig /all to find out what they are)
in fact u mixed Linux and Windows
Under Linux:
ifconfig -a
Under Windows:
ipconfig /all
but the tutorial was pretty good
thanks.
It is not necessary to uninstall the dhcp-client. Just ensure you use the spaces before the
lines
address, … in the interfaces file as shown above, then it works.
I found that if you are having problems connecting after all of this adding:
/sbin/route add -net 0.0.0.0 gw 1.1.1.1 eth0
where you have to replace 1.1.1.1 with the internal IP address of your router (gateway).
fixes your connection issues.
On the line ‘name server xxx.xxx.xxx.xxx’ replace the x with the IP of your name server.
(You can do ifconfig /all to find out what they are)
you mean on the line ‘nameserver xxx.xxx.xxx.xxx’ etc…
I don’t believe “ifconfig /all” is a valid linux command. (However, “ifconfig -a” is valid)
Niether command will list your nameservers, however.
(i before e, except after c)
minor error – the dhcp 3 package is named “dhcp3-client” (not dhcp-client3) Good guide
This is one of the best post that I have ever read. You have provided a great piece of
information. I will definitely share it with my other friends. Keep up the good work, I would
to stay in contact with your posts.
The Linux shell command ifconfig will not show you your nameserver, as stated in this
post, nor is there a valid /all switch to ifconfig. To find your currently set nameserver,
Hi
I am using my computer as a dedicated ubuntu 10.4 lucid server. And I am already in a big
network.
I would like the server ip stable .
Could you please map the ip address with the ifconfig -a results
I am confused with address and network entries.
I have mapped like this please some one tell me this is the correct mapping.
I am confused with the address and network entries.
address –> ifconfig -> HWaddr
netmask –>ifconfig ->Mask
network –> ifconfig -> inet addr
broadcast-> ifconfig -> Bcast
gateway –>route -> Gateway
nameserver -> dig ubunto.com -> SERVER
nameserver ->/etc/resolv.conf
I have used 3 linux commands ,ifconfig, route,dig to find these entries.
I mean HWaddr entry from the result of ifconfig is the address entry (!) Is that right ,
if not please some one help me.
Hello, thank you for this article! I have followed these directions and I can ping various
websites successfully. I have one problem though… I now can not ssh to my server. Is
there anything I need to change in openssh?
Shaina, you need root privileges to write those files. Start the editor with “sudo”, like “sudo
gedit /etc/network/interfaces”
Worked a treat.
Thanks heaps.
worked great! thought id change from dhcp as woul be changing IPs on all dev machines
every time gets new IP lol from router restart n such! thanks any help with doing this with
wireless belkin dongle?
Hi,
First time on this site, please ignore illiteracy….
from ifconfig, i am getting
eth0 Link encap:Ethernet HWaddr 00:0a:e6:ef:a6:af
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
My “interfaces” file has:
auto eth0
iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
I am using a single computer. What IP address I need to include in my resolv.conf as
nameserver ?
*****I tried:
nameserver 192.168.1.3 (since this is the ip address of my pc)
root@desk:/etc/network# ping http://www.google.com
ping: unknown host http://www.google.com
******I tried:
nameserver 192.168.1.1 (gateway of my router)
root@desk:/etc/network# ping http://www.google.com
works fine, resolving address
******I tried:
nameserver 192.168.1.3 (since this is the ip address of my pc)
nameserver 208.67.222.222(Open DNS)
nameserver 208.67.220.220(Open DNS)
root@desk:/etc/network# ping http://www.google.com
works fine, resolving address
******I tried:
nameserver 192.168.1.3 (since this is the ip address of my pc)
nameserver “my ISP Primary DNS”
nameserver “my ISP Secondary DNS”
root@desk:/etc/network# ping http://www.google.com
works fine, resolving address
Which way would be the right way to configure it?
And which way would be the right way to configure it if I want to run a web server using the
same machine?
Please please please help me
Hi,
First time on this site. Please ignore my illiteracy
I am trying to set a static ip on my pc to configure DNS. I have only 1 dedicated PC,
running ubuntu 9.10.
My interfaces file includes
auto eth0
iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
and on resolv.conf, I have tried:
nameserver 192.168.1.3
ping http://www.google.com -> unknown host, can’t brows internet
Tried:
nameserver 192.168.1.1
ping http://www.google.com -> works fine
Tried:
nameserver 192.168.1.3
nameserver Open DNS
ping http://www.google.com -> works fine
Tried:
nameserver 192.168.1.3
nameserver My ISP DNS
ping http://www.google.com -> works fine
Which one would be correct if I want this computer to be my nameserver in the network?
Which one would be correct if I want to run a web server from this computer using a static
ip provided my ISP?
name server should be nameserver … without this it will not resolve dns properly… Danke
Leave a Reply
Name (required)
Email (required)
Submit Comment
Our Friends Getting Started About How-To Geek What Is That Process?
stackoverflow.com [programming] Windows 7 Articles About Us svchost.exe wmpnscfg.exe Wfica32.exe
serverfault.com [sysadmin] Windows Vista Articles Contact Us jusched.exe rundll32.exe Mobsync.exe
superuser.com [computing] Get Help on our Forums Advertising dwm.exe wfcrun32.exe conhost.exe
How-To Geek Wiki Privacy Policy ctfmon.exe Ipoint.exe Dpupdchk.exe
ToolsGeek [Useful Online Tools]
wmpnetwk.exe Itype.exe Adobe_Updater.exe
How-To Geek Arcade Disclaimers
mDNSResponder.exe wlidsvc.exe SearchIndexer.exe
How-To Geek Reviews Comment Policy
How-To Geek ETC
Copyright © 2006-2010 HowToGeek.com. All Rights Reserved.