LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   My Static IP changes at night (https://www.linuxquestions.org/questions/linux-newbie-8/my-static-ip-changes-at-night-4175603629/)

NotionCommotion 04-11-2017 06:18 AM

My Static IP changes at night
 
I have a Centos machine in the crawlspace of my garage. I can't get wire to it, so am using wifi. I previously had it set up with both a 192.168.1.200 eth0 and 192.168.1.201 wlan0 (but obviously eth0 wasn't operational), and I recently changed it to 10.120.11.200 wlan0 only. I think all is good, but wake up in the morning and ssh into it from my living room, and my server is gone! I crawl into the crawlspace, and find the IP is now 10.120.11.140. I restart the network, and now it is back to 10.120.11.200. The top of the first image shows an ifconfig I had done yesterday and the second half is one I just did (yes, I know I shouldn't leave it looked on, but it is hidden in my crawlspace you know). The second image is me next restarting the network, and re-running ifconfig (off topic, how can I capture the screen without taking a picture?).

https://s1.postimg.org/farg683dr/img1.jpg EDIT. How do I include images in this post instead of links?

https://s7.postimg.org/di15gfhd7/img2.jpg

system-config-network-tui was used to make the changes. Several config settings are shown below.

What is causing this, and how can I keep it always as 10.120.11.200?

Thank you

Code:

[Michael@devserver dashboard]$ ifconfig
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:65536  Metric:1
          RX packets:14777 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11642564 (11.1 MiB)  TX bytes:11642564 (11.1 MiB)

wlan0    Link encap:Ethernet  HWaddr B8:76:3F:69:31:95
          inet addr:10.120.11.200  Bcast:10.120.11.255  Mask:255.255.255.0
          inet6 addr: fe80::ba76:3fff:fe69:3195/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2007915 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1676584 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:323627133 (308.6 MiB)  TX bytes:424732129 (405.0 MiB)

[Michael@devserver dashboard]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=devserver.michaels.lan
[Michael@devserver dashboard]$ cat /etc/resolv.conf
search michaels.lan hsd1.wa.comcast.net
nameserver 10.120.11.1
nameserver 8.8.8.8
nameserver 8.8.4.4
[Michael@devserver dashboard]$ cat /etc/hosts
127.0.0.1      localhost.localdomain  localhost.localdomain  localhost4      localhost4.localdomain4 localhost      devserver
::1    localhost.localdomain  localhost.localdomain  localhost6      localhost6.localdomain6 localhost      devserver
[Michael@devserver dashboard]$ cat /etc/sysconfig/network-scripts/ifcfg-wlan0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=10.120.11.1
# DNS1=8.8.8.8
DEVICE=wlan0
BOOTPROTO=none
NETMASK=255.255.255.0
# DNS2=8.8.4.4
TYPE=Ethernet
HWADDR=b8:76:3f:69:31:95
IPADDR=10.120.11.200
NM_CONTROLLED=no
ONBOOT=yes
PEERDNS=no
DNS2=4.4.4.4
DNS1=8.8.8.8
IPV6INIT=no
USERCTL=no
[Michael@devserver dashboard]$


Rickkkk 04-11-2017 07:01 AM

Hey NotionCommotion ..

Have you made sure your router is assigning a fixed IP address to the computer in the crawl space through a DHCP reservation ? You either have to do that or turn off DHCP altogether and use local fixed IP addresses for every computer on your network.

If it's not that, I'm not sure what is causing the IP address to change like that.

Cheers,

NotionCommotion 04-11-2017 07:28 AM

Hey Rickkk! You are right!

I looked at the router, and it shows the device in question as DHCP. I definitely don't want to use DHCP across the board. Looking at the router settings, I don't think I could fix things from that end. I think I have to tell the Linux server to tell the router not to use DHCP.

I am thinking I just need to change BOOTPROTO=none to BOOTPROTO=static in /etc/sysconfig/network-scripts/ifcfg-wlan0. Guess I could/should also get rid of DNS1 and DNS2, but think it might not hurt anything.


EDIT. Nope. Made the changes, and router still shows as DHCP.
https://s10.postimg.org/71zg1iidl/Capture.png
Code:

[Michael@devserver application]$ cat /etc/sysconfig/network-scripts/ifcfg-wlan0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=10.120.11.1
# DNS1=8.8.8.8
DEVICE=wlan0
#BOOTPROTO=none
BOOTPROTO=static
NETMASK=255.255.255.0
# DNS2=8.8.4.4
TYPE=Ethernet
HWADDR=b8:76:3f:69:31:95
IPADDR=10.120.11.200
NM_CONTROLLED=no
ONBOOT=yes
PEERDNS=no
#DNS2=4.4.4.4
#DNS1=8.8.8.8
IPV6INIT=no
USERCTL=no
[Michael@devserver application]$ sudo /etc/init.d/network restart
Shutting down interface wlan0:                            [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface wlan0:  Determining if ip address 10.120.11.200 is already in use for device wlan0...
                                                          [  OK  ]
[Michael@devserver application]$ ifconfig
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:65536  Metric:1
          RX packets:14777 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11642564 (11.1 MiB)  TX bytes:11642564 (11.1 MiB)

wlan0    Link encap:Ethernet  HWaddr B8:76:3F:69:31:95
          inet addr:10.120.11.200  Bcast:10.120.11.255  Mask:255.255.255.0
          inet6 addr: fe80::ba76:3fff:fe69:3195/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2092182 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1748345 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:336993793 (321.3 MiB)  TX bytes:442458736 (421.9 MiB)

[Michael@devserver application]$


Rickkkk 04-11-2017 07:39 AM

Quote:

Originally Posted by NotionCommotion (Post 5695555)
Hey Rickkk! You are right!

I looked at the router, and it shows the device in question as DHCP. I definitely don't want to use DHCP across the board. Looking at the router settings, I don't think I could fix things from that end. I think I have to tell the Linux server to tell the router not to use DHCP.

I am thinking I just need to change BOOTPROTO=none to BOOTPROTO=static in /etc/sysconfig/network-scripts/ifcfg-wlan0. Guess I could/should also get rid of DNS1 and DNS2, but think it might not hurt anything.

Hey NotionCommotion,

If for some reason you have set up your WLAN interface to use a static IP, but it is still getting overwritten by the router, you can configure your router to fix this. Short of disabling DHCP completely on the router (which might make your life more complicated for other computers in your home), the best way to make sure that your crawl space computer is always assigned the same IP is to use your router's DHCP reservation function.

You just need to pair the crawl space computer's WLAN MAC address with the IP you want to assign, change the configuration of the WLAN interface on your crawl space box to use DHCP instead of a static IP, and thereafter its IP address should remain the same. I always manage fixed IP addresses through DHCP reservation as opposed to configuring static IPs on each computer - it's much simpler since management is centralized on the router.

Cheers,

vincix 04-11-2017 08:25 AM

First of all, is your lan subnet 10.120.x.x or 192.168.x.x? You first say that you configured your server with an ip belonging to the 192.168.x.x lan, but then you say that all of a sudden the dhcp (most probably) assigned you a 10.120.x.x ip. This doesn't really make any sense. I can see that everyone here supposed that you're talking about IPs belonging to the same subnet.

So if we assume that, my suggestion is to simply change the dhcp pool. I think that's the easiest thing you can do. Just use, for instance 10.120.11.100-.254 for dhcp and you can assign static IPs starting from .2 (I'm guessing .1 is the router) to .99. And the rest of the devices can still use dhcp.

@NotionCommotion, as far as I know, BOOTPROTO=static doesn't exist. Only none actually exist, but in principle the effect should be the same, i.e. not use dhcp.

For static ips, if you're using centos, for instance, you also need to add the gateway in /etc/sysconfig/network:
GATEWAY=10.120.11.1

NotionCommotion 04-11-2017 09:36 AM

Quote:

Originally Posted by vincix (Post 5695573)
First of all, is your lan subnet 10.120.x.x or 192.168.x.x? You first say that you configured your server with an ip belonging to the 192.168.x.x lan, but then you say that all of a sudden the dhcp (most probably) assigned you a 10.120.x.x ip. This doesn't really make any sense. I can see that everyone here supposed that you're talking about IPs belonging to the same subnet.

So if we assume that, my suggestion is to simply change the dhcp pool. I think that's the easiest thing you can do. Just use, for instance 10.120.11.100-.254 for dhcp and you can assign static IPs starting from .2 (I'm guessing .1 is the router) to .99. And the rest of the devices can still use dhcp.

@NotionCommotion, as far as I know, BOOTPROTO=static doesn't exist. Only none actually exist, but in principle the effect should be the same, i.e. not use dhcp.

For static ips, if you're using centos, for instance, you also need to add the gateway in /etc/sysconfig/network:
GATEWAY=10.120.11.1


Thanks vincix. No, I previously had it set up with both a 192.168.1.200 eth0 and 192.168.1.201 wlan0..., and I recently changed it to 10.120.11.200 wlan0 only. Also, my gateway is good as I originally showed. I've have a couple eth0 machines set up as static using the same router, and all is good. Is it because it is wireless? Maybe I also create an unused eth0 static ip on the machine, but it sounds like there is probably a more correct why to handle.

Code:

[Michael@devserver dashboard]$ cat /etc/sysconfig/network-scripts/ifcfg-wlan0
...
GATEWAY=10.120.11.1
...


vincix 04-11-2017 09:45 AM

IF the IPADDR directive and the BOOTPROTO=none were there in ifcfg-wlan0, I really don't understand what could have made your server to change the ip, unless you're using another network tool to connect to your router through wifi, which, in turn, switches to dhcp. Maybe there's a conflict between the two.

Anyway, you should really use an IP outside the dhcp pool, otherwise you might end up with connection problems. Change the dhcp pool so that you have a range of static ips - this way you won't have to bother yourself with ip reservation - especially if this is a server(-like). One doesn't have dhcp reservations for servers (normally).

Rickkkk 04-11-2017 10:00 AM

Quote:

Originally Posted by vincix (Post 5695613)
... One doesn't have dhcp reservations for servers (normally).

Although I agree with this for a business environment, I personally opt for the DHCP reservation method for servers and all machines on my home network. It just makes management so much simpler, given that it is centralized on the router.

Both methods work, though, so the OP has a choice.

Cheers :-)

NotionCommotion 04-11-2017 10:17 AM

Thanks guys,

I change the pool range, saved, and it still showed up as dhcp. Finally tried rebooting my browsers, and it finally took.

Rickkkk 04-11-2017 10:23 AM

Quote:

Originally Posted by NotionCommotion (Post 5695631)
Thanks guys,

I change the pool range, saved, and it still showed up as dhcp. Finally tried rebooting my browsers, and it finally took.

Good news - Cheers !


All times are GMT -5. The time now is 07:11 AM.