Page 1 of 2
Setting Up A Static IP Address
Posted: Sun Nov 29, 2020 8:15 pm
by jca
I am trying to setup my MISTer with a static address.
For reasons too long to discuss I am not in a position to use the MAC address and setup the IP in the router.
So far I used:
ifconfig eth0 192.168.80.38 netmask 255.255.255.0
route add default gw 192.168.80.254
echo "nameserver 8.8.8.8" > /etc/resolv.conf
It works .. until I reboot because the DHCP server is still running.
I could not find dhcpconfig or the DHCP manager to disable the dhcp service.
In edited the file /etc/network/interfaces and replaced each occurrence of dhcp with static but it did not work.
I suspect I am on the right track but the order to do it may be the problem.
Any help would be highly appreciated.
Re: Setting Up A Static IP Address
Posted: Mon Nov 30, 2020 12:36 am
by pgimeno
Re: Setting Up A Static IP Address
Posted: Wed Dec 02, 2020 7:28 pm
by jca
Thanks for the link. It did not really help but I followed some links which lead me to other links (almost ad infinitum).
I tried quite a few things like totally scraping the /etc/network/interfaces file and replacing it with
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.80.38
netmask 255.255.255.0
gateway 192.168.80.254
dns-nameservers 8.8.8.8
When booting MISTer and going really fast to the screen which displays the IP I could see that I was getting the right IP but a few seconds it displayed the old DHCP address. At that point MISTer had 2 IP addresses and I could ssh or ftp using either one.
I edited the dhcpcd.conf file to prevent dhcp assigning a dhcp address to eth0 with
denyinterfaces eth0
No change
I renamed the dhcpcd client to something else: no change.
I restored the interfaces files to its original status and edited again the dhcpcd.conf file:
I removed the denyinterfaces and added
interface eth0
static ip_address=192.168.80.38/24
static routers=192.168.80.254
static domain_name_servers=192.168.80.3 8.8.8.8
Same darn thing, I am going insane.
Help, help, help.
Re: Setting Up A Static IP Address
Posted: Wed Dec 02, 2020 7:37 pm
by shira
Re: Setting Up A Static IP Address
Posted: Wed Dec 02, 2020 9:01 pm
by zakk4223
It's because mister uses 'connmand' to configure the interface, and I guess it isn't smart enough to not dhcp if it already has an address?
Anyways, setup your /etc/network/interfaces with the static config, and then create the file /etc/connman/main.conf (if the directory isn't there create it) and put these two lines in it:
[General]
NetworkInterfaceBlacklist=eth0
There is also a way to use connmanctl to set a static ip address that will save in /var/lib/connman (you have to create that directory) but that seems overly complicated compared to the interfaces file
Re: Setting Up A Static IP Address
Posted: Wed Dec 02, 2020 9:35 pm
by jca
Thanks for the info, I will try it later when I am back home.
Shall I trash all the stuff related to wlan0 and wlan1 from the interfaces file? I do not use WiFi.
Something like that:
# interface file auto-generated by buildroot
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.80.38
netmask 255.255.255.0
gateway 192.168.80.254
dns-nameservers 8.8.8.8
Re: Setting Up A Static IP Address
Posted: Wed Dec 02, 2020 9:39 pm
by zakk4223
There's no harm in leaving the wlan0/1 stuff there; just add your eth0 config to the end
Re: Setting Up A Static IP Address
Posted: Thu Dec 03, 2020 2:28 pm
by jca
Thanks for the help, I am ALMOST there.
At the moment I just replaced the interface file with what I mentioned in my previous post, ditching the wlan stuff.
I created the directory and file /etc/connman/main.conf.
Now I can start MISTer and get the fixed IP. No extra IP like before. I can ftp and ssh.
Only problem left: no internet.
Thinking of a routing problem I issued
route add default gw 192.168.80.254, still nothing.
route -en gives
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.80.254 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.80.254 0.0.0.0 UG 0 0 0 eth0
192.168.80.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
I can ping the gateway, I have internet on my PC.
Re: Setting Up A Static IP Address
Posted: Thu Dec 03, 2020 6:25 pm
by jca
Problem solved:
Although I have
dns-nameservers 8.8.8.8
in the interface file the contents of /etc/resolv.conf was just the loopback address.
echo "nameserver 8.8.8.8" >/etc/resolv.conf resolved (no pun intended) the problem.
I just checked the man page for interface and dns-nameservers does not appear.
On my first attempts to setup a fixed IP I was using the echo method. On my last failed attempt I found this dns-nameservers thing on the internet and thought is was cool. No so cool in the end.
Many thanks to zakk4223.
Re: Setting Up A Static IP Address
Posted: Tue Dec 08, 2020 1:42 pm
by jca
My problem is only partially solved:
The setting in /etc/resolv.conf is not permanent. After a reboot it reverts to:
# Generated by Connection Manager
nameserver 127.0.0.1
connman is recreating the file. I do not know anything about connman; I tried looking on the internet but so far without any result.
I could write a script to overwrite resolv.conf and run it after booting but it would be a band-aid.
Does anyone knows how to fix it?
Re: Setting Up A Static IP Address
Posted: Thu Dec 10, 2020 7:28 pm
by Johnny Love
You can make any script run at boot by putting it in/etc/init.d, but I would start the filename with 9999 to make sure it runs last. Obviously not the ideal fix, but it beats running a script manually every time. Also expect the script to get wiped after linux gets updated, which is not that often. A backup of it in /media/fat should be fine.
Re: Setting Up A Static IP Address
Posted: Thu Dec 10, 2020 8:45 pm
by jca
Thanks for this idea.
I will also put my script which keeps my USB HDD spinning. I will try it when I am back home.
Re: Setting Up A Static IP Address
Posted: Fri Dec 11, 2020 7:29 pm
by jca
Johnny Love wrote: ↑Thu Dec 10, 2020 7:28 pm
You can make any script run at boot by putting it in/etc/init.d, but I would start the filename with 9999 to make sure it runs last. Obviously not the ideal fix, but it beats running a script manually every time. Also expect the script to get wiped after linux gets updated, which is not that often. A backup of it in /media/fat should be fine.
After another major power failure of 8 hours I finally wrote 2 scripts which I put in init.d:
S99dns for internet access and S99spin to have my USB drive spinning forever, now I don't have to manually execute scripts after booting MISTer.
Many thanks
Johnny, I
Love you
Re: Setting Up A Static IP Address
Posted: Wed Sep 22, 2021 8:26 am
by Zarkov
Hi there, I'm also trying to setup static ip on my mister and found this thread.
I was only successful getting my mister online and updating by using the pre patch "connmanctl" command. Once the mister was updated, this command is now gone.
I followed your info and got my ip, netmask, gateway, and that dns-nameservers setup in my interfaces file
I can not get the dns to work in the resolv.conf file. It says its managed by dhcpcd.
Thanks for your time.
Re: Setting Up A Static IP Address
Posted: Wed Sep 22, 2021 2:22 pm
by Flandango
Network configuration is now done with dhcpcd. You will have to modify the
/etc/dhcpcd.conf file to setup a static ip.
Add something like this on the bottom of the file:
Code: Select all
interface eth0
static ip_address=192.168.0.XX/24
static routers=192.168.0.X
static domain_name_servers=192.168.0.X 8.8.8.8
For DNS, you don't need to Provide more than one but if you do, just leave a space between them.
The Static IP address has the /24 for the netmask, if you don't know what your network has, then leave it as /24 as that's the most common for home networks.
As a side note, copy this file to your SD Card as a backup, since updates can reset, if it does, just copy it back over.
If you are script savvy, you can probably write a script to check if the files match, if they don't copy it over and include it in the
/media/fat/linux/user-startup.sh startup script.
Re: Setting Up A Static IP Address
Posted: Wed Sep 22, 2021 8:49 pm
by Zarkov
Flandango wrote: ↑Wed Sep 22, 2021 2:22 pm
Network configuration is now done with dhcpcd. You will have to modify the
/etc/dhcpcd.conf file to setup a static ip.
Add something like this on the bottom of the file:
Code: Select all
interface eth0
static ip_address=192.168.0.XX/24
static routers=192.168.0.X
static domain_name_servers=192.168.0.X 8.8.8.8
For DNS, you don't need to Provide more than one but if you do, just leave a space between them.
The Static IP address has the /24 for the netmask, if you don't know what your network has, then leave it as /24 as that's the most common for home networks.
As a side note, copy this file to your SD Card as a backup, since updates can reset, if it does, just copy it back over.
If you are script savvy, you can probably write a script to check if the files match, if they don't copy it over and include it in the
/media/fat/linux/user-startup.sh startup script.
Thank you this helped me.
Re: Setting Up A Static IP Address
Posted: Wed Sep 22, 2021 11:57 pm
by jalbarracin
Thank you! had a little time to understand it and change it for wireless lan:
Code: Select all
interface wlan0
static ip_address=192.168.1.222/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
As in the example, instead of eth0, for wireless you should write wlan0
in my case my ip addresses range from 192.168.1.1 to 192.168.1.255 so I selected 222
my gateway router is on 192.168.1.1
Just sharing this modification for others to inspire
Re: Setting Up A Static IP Address
Posted: Thu Sep 23, 2021 1:33 am
by Zarkov
Perhaps the GitHub page for network access should be updated to reflect the new way of doing static. It’s still suggesting connmanctl
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 5:47 am
by kahuna
Hi there,
Quick question if I may.
I had a static IP address configured, I updated to the latest MiSTer distro and now all my custom configs are gone.
Is there a way to make them persist after upgrades?
Thanks!
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 7:11 am
by Crystal
kahuna wrote: ↑Sun Sep 26, 2021 5:47 am
Hi there,
Quick question if I may.
I had a static IP address configured, I updated to the latest MiSTer distro and now all my custom configs are gone.
Is there a way to make them persist after upgrades?
Thanks!
while OP cant, why not set up static lease on your router instead? if you can, i'd imagine it's the easier and more reliable solution in this case
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 12:05 pm
by jca
It may not always be possible. sure, it is easier using the MAC address to do it but I doubt it is more reliable.
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 2:34 pm
by kahuna
So, I guess there’s no way of saving your custom configuration and that to persist upgrades. Isn’t it?
I also changed the root password and the .bashrc among other small things to make it more usable for me.
Thanks!
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 2:50 pm
by Crystal
jca wrote: ↑Sun Sep 26, 2021 12:05 pm
It may not always be possible. sure, it is easier using the MAC address to do it but I doubt it is more reliable.
why wouldnt it be reliable? if you dont change router configuration, it will be reliable. i also have a raspberry pi, where i clean upgrade the system relatively often, so its actually lot more comfortable to set it up on router, where these settings will stay, no matter what changes on client side[like de10-nano in this case]. id say its more reliable, if you can take advantage of it. maybe you are not the admin on the router where you connect, maybe you have other restriction, in which case, sure, setting up static ip on de10-nano makes sense,as an alternative[a less reliable alternative, since how mister updates are handled]
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 3:27 pm
by jca
I did not say it was not reliable I just said I doubted it was MORE reliable. Being more convenient does not mean more reliable.
With the new dhcpcd I just one file to copy back after a Linux update, no big deal.
Re: Setting Up A Static IP Address
Posted: Sun Sep 26, 2021 3:52 pm
by Crystal
if we see anything, is that static ip on mister is unreliable, if you want to use any of the updater. first and foremost, its the dhcp server's job, which probably runs on your router, to handle ip assignment and lease. its definitely more reliable to handle it on server side, instead of client side[if you can. if you cant, you dont have a choice. otherwise, do it server side]
Re: Setting Up A Static IP Address
Posted: Mon Sep 27, 2021 6:35 am
by Stupid Dufus
I've got mine set to static on the router side, though after a linux update for mister a few weeks ago, the MAC address changed and had to redo that. But that's the first time it's happened to me since I got mine a year or so ago.
Re: Setting Up A Static IP Address
Posted: Sat Apr 23, 2022 10:29 am
by yoshi41
I use a couple of shell scripts to set static (and dhcp) ip and mac address. Just change the variables in the script for your network setup and run it on the linux shell. It sometimes works from the MiSTer menu, but most of the time /etc is not writeable.
What it does:
- setup /etc/network/interfaces
- setup dns server
- disable (or enable) dhcp client daemon
- setup mac address
The scripts can be found in the attached zip file.
Re: Setting Up A Static IP Address
Posted: Wed May 17, 2023 5:49 pm
by gibs
yoshi41 wrote: ↑Sat Apr 23, 2022 10:29 am
I use a couple of shell scripts to set static (and dhcp) ip and mac address. Just change the variables in the script for your network setup and run it on the linux shell. It sometimes works from the MiSTer menu, but most of the time /etc is not writeable.
What it does:
- setup /etc/network/interfaces
- setup dns server
- disable (or enable) dhcp client daemon
- setup mac address
The scripts can be found in the attached zip file.
Thanks but from what I see, it set-up the mac address for eth0.
my issue is on wlan0.
I did the change in u-boot.txt manualy and it did not work.
Re: Setting Up A Static IP Address
Posted: Wed May 17, 2023 6:44 pm
by yoshi41
Each wifi adapter has it‘s own unique mac (hardware) address. There is no need to change it.
The mac address for eth0 is by default the same for every MiSTer. This is a problem if you have more than one MiSTer in your network. In this case, you can assign your own unique mac address.
Re: Setting Up A Static IP Address
Posted: Mon May 22, 2023 6:18 am
by akeley
I've been struggling with this for quite some time now. Nearly every time I try to log in to MiSTer via WinSCP it fails, because the IP (displayed in the OSD) is different.
I know nothing about networking, it's always been my Kryptonite, so would like to use yoshi41's script. I tried to do it from WinSCP but don't know what command to use - I only get these "not understood errors"
- sshot-2023-05-22-13-55-50.png (23.75 KiB) Viewed 8539 times