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 |
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, |
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 |
Quote:
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, |
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 |
Quote:
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 |
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). |
Quote:
Both methods work, though, so the OP has a choice. Cheers :-) |
Thanks guys,
I change the pool range, saved, and it still showed up as dhcp. Finally tried rebooting my browsers, and it finally took. |
Quote:
|
All times are GMT -5. The time now is 07:11 AM. |