LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP changes when device restarts (https://www.linuxquestions.org/questions/linux-newbie-8/ip-changes-when-device-restarts-4175597769/)

wBB 01-18-2017 07:12 PM

IP changes when device restarts
 
Hi!
I have worked with the 8.6 Linux Debian distribution on a device called BeagleBone Black (also called BBB), in which I need to set up a fixed IP. I already managed to set up, but when the BBB is restarted, the IP goes back to the old number.

I am doing this:

1- Connect the BBB physically to the router;
2 - I verified by the router which dynamic IP the BBB got and then access as root user via SSH in a terminal (like Putty);
3- I edit the file "/etc/network/interfaces" and enter the information I need, like this:
Code:

#Interface Eth0
auto eth0
iface eth0 inet static
network 192.168.0.0
address 192.168.0.15
netmask 255.255.255.0
gateway 192.168.0.1
broadcast 192.168.0.255
dns-server 192.168.0.1

4- I edit the file "/etc/resolv.conf" and change the "nameserver" to "nameserver 192.168.0.1" (this is the IP of my router)
5- After this I reboot the network: /etc/init.d/networking restart

So far so good! I can access the BBB through the new IP 192.168.0.15 (this is the IP that I chose).

THE PROBLEMS ARE:
When the BBB is turned OFF and ON again, this occurs:
A) The BBB again picks up a dynamic IP from the router;
B) The file "/etc/resolv.conf" returns to its original configuration, which is "nameserver 127.0.0.1".

The file "/etc/network/interfaces" remains with the information I put in, but it's as if it has no effect.

I have already verified a lot of information about the same problems, but maybe because of my lack of knowledge I was unable to solve the problem, although I have tried several alternatives.

I need this IP to stay fixed. I need to turn OFF the BBB, disconnect from the router and connect via CROSS cable to my laptop.

Does anyone have an idea how to solve it?

ferrari 01-18-2017 07:38 PM

Is that your entire working file, or are there some other active entries present?

ferrari 01-18-2017 07:58 PM

A bit more searching and I've found references (concerning Debian Jessie) that suggest configuring /etc/dhcpcd.conf instead.

For example
https://nebulousthinking.wordpress.c...essie-in-2016/

Quote:

If you want the static IP to happen on your Ethernet (hard-wired) network connection, then add lines like this to the top of the file – before the first comment:
Code:

interface eth0
static ip_address=192.168.0.15/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1


Another example of this..
http://superuser.com/questions/54711...pcd-still-runs

wBB 01-20-2017 12:46 PM

ferrari,
there is no "dhcpcd.conf" file at this Linux Debian distribution.
So the two examples you indicated do not solve the problem in this case.
PS: I have very little knowledge about Linux, so if you have a little more patience and help me a bit more, I would be very grateful!

wBB 01-20-2017 07:33 PM

SOLUTION:

It had nothing to do with anything that was quoted. It occurs in Debian Linux, of several versions (mine is Jessie 8.6), there is a connection management package that overwrites some information and simply ignores others, such as the file information "interfaces" I mentioned above. This management pack is called "connman" and can be verified at the debian.org site at the address below:
https://packages.debian.org/search?keywords=connman

HOW TO KEEP FIXED IP ON DEBIAN JESSIE:

1- Edit the file "/etc/network/interfaces" and add (or edit) at the end of file, the lines below, adapting the information of your network or a fictitious network, at your discretion:
Code:

#Interface Eth0
auto eth0
iface eth0 inet static
network 192.168.0.0
address 192.168.0.15
netmask 255.255.255.0
gateway 192.168.0.1
broadcast 192.168.0.255
dns-server 192.168.0.1

2- Edit the file "/etc/resolv.conf" and change the "nameserver". In my case I put the IP of my router and another one:
nameserver 192.168.0.1
nameserver 8.8.8.8

3- Locate the "connman" service. Make sure what name it takes on your Linux distribution. In my case it was "connman" anyway. To list the services running: ps -aux

4. Uninstall the "connman" service: apt-get purge connman

5. Restart Linux: reboot.

That way my device still worked connected to the router, being possible to access it by IP 192.168.0.15, which was the IP that I chose. But it is also possible to access directly through a cable connected between the device and the laptop.


All times are GMT -5. The time now is 12:41 PM.