LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2017, 06:18 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Rep: Reputation: Disabled
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]$
 
Old 04-11-2017, 07:01 AM   #2
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch
Posts: 1,252

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
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,
 
Old 04-11-2017, 07:28 AM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Original Poster
Rep: Reputation: Disabled
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]$

Last edited by NotionCommotion; 04-11-2017 at 07:34 AM.
 
Old 04-11-2017, 07:39 AM   #4
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch
Posts: 1,252

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Quote:
Originally Posted by NotionCommotion View Post
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,

Last edited by Rickkkk; 04-11-2017 at 07:41 AM.
 
1 members found this post helpful.
Old 04-11-2017, 08:25 AM   #5
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,182

Rep: Reputation: 90
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

Last edited by vincix; 04-11-2017 at 08:28 AM.
 
Old 04-11-2017, 09:36 AM   #6
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by vincix View Post
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
...
 
Old 04-11-2017, 09:45 AM   #7
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,182

Rep: Reputation: 90
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).
 
1 members found this post helpful.
Old 04-11-2017, 10:00 AM   #8
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch
Posts: 1,252

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Quote:
Originally Posted by vincix View Post
... 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 :-)
 
Old 04-11-2017, 10:17 AM   #9
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Original Poster
Rep: Reputation: Disabled
Thanks guys,

I change the pool range, saved, and it still showed up as dhcp. Finally tried rebooting my browsers, and it finally took.
 
Old 04-11-2017, 10:23 AM   #10
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch
Posts: 1,252

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Quote:
Originally Posted by NotionCommotion View Post
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 !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
setting static IP on linux PCs with no static IP address from internet provider? solvetek Linux - Networking 1 10-22-2011 08:04 AM
How to initialize a static array of a class in a static member function lali.p Programming 9 02-16-2008 09:27 AM
Howto Assign Multiple Static Public IP Addresses under SBC's PPPoE Static Ip system o trekgraham Linux - Networking 8 04-17-2007 10:51 AM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 11:13 AM
Last night's upgrade RH9 - Now "static" when online? Seamaiden Linux - General 4 02-23-2004 05:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:05 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