LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-11-2009, 12:48 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
How to make a network address permanent?


I run Linux both on my desktop and my notebook. I sinchronize data often with rsync, so I wrote a script. Today, my script could not SSH to my notebook. A little investigation revealed that the notebook's address on the network had changed from 192.168.1.104 to 192.168.1.103. Why did that happen, and how do I keep that from happening again?
 
Old 09-11-2009, 12:55 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You probably use DHCP
Setup a fixed IP in networkmanager or whatever you use to connect.
 
Old 09-11-2009, 12:59 PM   #3
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Most likely your interfaces are configured to use DHCP. Changing that to static would solve the problem.

Don't know Kubuntu but if I'm correct it's Debian based so I would think you have a file called interfaces in the /etc/network directory.

In there you have your configuration parameters for the NIC. Check if it's set to DHCP and if so change it to static.

Kind regards,

Eric
 
Old 09-11-2009, 02:33 PM   #4
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
This is my /etc/network/interfaces files:

Code:
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0
How do I change that?
 
Old 09-11-2009, 02:41 PM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Is that all you have in your interfaces file? That's just the reference to your loopback interface. You should have a eth0 reference in there. Can you check that? Also have you done some upgrading or something? Since you mentioned it was working before and you have another IP address, this strikes me as odd that you don't have an eth reference.

Kind regards,

Eric
 
Old 09-11-2009, 02:57 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Do you want to do this the 'big network' way, or the 'make the minimum amount of trouble for me, today' way?

The first would be to use names for capabilities (eg, fileserver1, or something) and then your script would refer to fileserver1 (ok, fs1 would be more convenient) and if your network ever changes, you just have to ensure that there is still a machine called fs1, even if it is not the same machine.

The real 'big network' way of doing this is with DNS, but you haven't said anything that suggests a necessity for that; you don't actually need DNS, you can 'hard code' the ips in the traditional way in /etc/hosts.conf, /etc/resolv.conf, /etc/hosts way (actually, doesn't debian use 'interfaces' unlike the RH-alike derivatives, so I assume that ubuntu does the same thing...there is probably some easy config tool, though, isn't there?).

If, as has been suggested, you are using dhcp, there are various ways to work around this, although it depends a bit on your dhcp server (ISC DHCP is pretty flexible, but the servers built into some networking equipment, while still workable, are less flexible).
  • you can force the server to hand out a predetermined IP address. You can wonder whether this actually making your life any easier than hard coding the IPs, but it can be helpful if you move machines from one network to another
  • you can turn off DHCP altogether
  • you can hard code some IP addresses and use DHCP for others

This is probably more choice than you need. Try http://www.linuxhomenetworking.com/, or more particularly http://www.linuxhomenetworking.com/w...nux_Networking for more detail.
 
Old 09-11-2009, 03:18 PM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
From your original post I'm assuming that you don't have a DNS server, DHCP server or such configured and that your router is handing out IP addresses.

If you want to hardcode them in the interfaces file just put in this, assuming your networkcard is named eth0.
Code:
iface eth0 inet static
address 192.168.1.XX (the one you want to assign)
netmask 255.255.255.0
gateway 192.168.1.1  (the IP of your router)
dns-nameservers XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX (replace with your dns)
After that give the command on a console
Code:
ifup eth0
and that should do the trick. If you get any errors or questions just post them.

Kind regards,

Eric
 
Old 09-12-2009, 02:46 AM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
What linux version are you using, which windowmanager?
Do you use networkmanager or wicd to connect?
If you use networkmanager, you need to use networkmanager to change from DHCP to fixed IP, and
/etc/network/interfaces can only contain the loopback interface.

Double click or right click on the icon in your taskbar which shows the connectivity, and set it to fixed IP instead of DHCP.

However, if you recieved the IP from the router via DHCP, you need to exclude the IP you want to set as fixed,
in order to prevent that the IP will be given to another computer in your network, and cause conflicts in your network.

Last edited by repo; 09-12-2009 at 04:47 AM.
 
Old 09-12-2009, 03:03 AM   #9
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
I stand corrected. I'm used to working on console with no GUI installed. Only recently started with desktop Linux (Slackware, Ubuntu, Debian). Thanks for pointing this out repo.

Kind regards,

Eric
 
Old 09-12-2009, 07:52 AM   #10
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by EricTRA View Post
From your original post I'm assuming that you don't have a DNS server, DHCP server or such configured and that your router is handing out IP addresses.

If you want to hardcode them in the interfaces file just put in this, assuming your networkcard is named eth0.
Code:
iface eth0 inet static
address 192.168.1.XX (the one you want to assign)
netmask 255.255.255.0
gateway 192.168.1.1  (the IP of your router)
dns-nameservers XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX (replace with your dns)
After that give the command on a console
Code:
ifup eth0
and that should do the trick. If you get any errors or questions just post them.

Kind regards,

Eric
I followed these instructions and lost connection completely after reboot. My usual connections all dispappeared from nm-applet. I tried to create a new one again, but it wouldn't save. I just clicked OK, the widget accepted it, but it didn't save. I rebooted 3 times and couldn't get a connection again.

So I deleted those lines from /etc/network/interfaces and it's all working again.

I am using nm-applet on Kubuntu Jaunty with KDE 3.5.

https://wiki.kubuntu.org/Kubuntu/Kde3/Jaunty

Knetwork manager is reported not to work, so I have nm-applet, which is set to DHCP. If I set it to "Manual", I am supposed to enter address, netmask and gateway. And there is a "Routes" button that brings up a similar dialog to fill in. Networking is always so confusing! But it seems to be working now. I ignored the "Routes" button, just filled in the rest, rebooted and got the IP address that I wanted. Many thanks.

I don't like how dependent all these Linux distros makes us to be on desktop network managers. So if I login as root (or even user) on a pure console session, I have no Internet? :-\
 
Old 09-12-2009, 09:14 AM   #11
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
With most distros you can leave it set to dhcp AND fill in the IP. When you do it this way it asks the router's dhcp server for that specific address(no changes required on router settings). The problem that can arise is that if another computer already has that IP, it will fail. There is a way around this. Most DHCP servers have a range that they use, typically starting at .100 and continuing a set(user set) amount. When they assign IPs they usually start at the bottom and go up. So instead of starting at the bottom for your quasi static address, you start at the top. In my case the router's IPs start at .100 and go 50, so I assign my first address as .150, second .149, etc. I assign all my addresses this way. Now when someone brings in a stray computer and hooks up I pretty much know that it will get assigned the .100 IP (first available number). This also assures that no matter the order the machines are booted in they will always have the same IP, without having to adjust router settings. The downfall is that you have to go through and edit all you scripts to use the new IPS, but this is a one time PITA.
 
Old 09-12-2009, 09:52 AM   #12
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
I don't like how dependent all these Linux distros makes us to be on desktop network managers. So if I login as root (or even user) on a pure console session, I have no Internet? :-\
As told before, you don't need to use networkmanager or any applet, just make the changes in
/etc/networking/interfaces, and your connection will work at boot.
However, networkmanager doesn't work with this solution,
That's why most people use wicd.

Ubuntu is known to be very user friendly, so everything is setup using applets and X
Most beginners just want a distro to work, with no hassle, like windows did.

You still can configure everything using the CLI though

Kind regards


BTW, you can mark the thread solved if you want.

Last edited by repo; 09-12-2009 at 09:55 AM.
 
Old 09-12-2009, 11:15 AM   #13
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by lazlow View Post
The downfall is that you have to go through and edit all you scripts to use the new IPS, but this is a one time PITA.
It's only two or three scripts, so it's no big deal.


Quote:
Originally Posted by repo View Post
As told before, you don't need to use networkmanager or any applet, just make the changes in
/etc/networking/interfaces, and your connection will work at boot.
However, networkmanager doesn't work with this solution, That's why most people use wicd.

You still can configure everything using the CLI though
What would the procedure be to set this up on the CLI so that the connection is available immediately after boot regardless of the graphical environment?
 
Old 09-12-2009, 11:23 AM   #14
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
What would the procedure be to set this up on the CLI so that the connection is available immediately after boot regardless of the graphical environment?
Uninstall networkmanager
Then setup the network like EricTRA told you
Or install wicd, it will make the connection, before the GUI is started.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
the following address had a permanent error igsen Linux - Newbie 3 04-17-2009 05:43 AM
Permanent Ethernet Address tuhinbose Linux - Hardware 1 01-09-2008 04:42 AM
Making default gateway address permanent in SuSe 10 alienmagic SUSE / openSUSE 9 01-02-2008 10:29 AM
how do i make network setting permanent? taoweijia Linux - Newbie 3 02-22-2004 11:02 PM
Permanent IP address linksocc Linux - Networking 2 10-10-2003 10:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration