Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
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.
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.
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.
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.
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? :-\
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.
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
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
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.