Setting Up A Static IP Address
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Setting Up A Static IP 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.
- pgimeno
- Top Contributor
- Posts: 709
- Joined: Thu Jun 11, 2020 9:44 am
- Has thanked: 277 times
- Been thanked: 226 times
Re: Setting Up A Static IP Address
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
Thanks for the link. It did not really help but I followed some links which lead me to other links (almost ad infinitum).pgimeno wrote: ↑Mon Nov 30, 2020 12:36 am Maybe this helps?
https://wiki.debian.org/NetworkConfigur ... e_manually
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
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
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
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
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
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.
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
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.
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
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?
-
- Posts: 12
- Joined: Sun Aug 16, 2020 3:51 pm
Re: Setting Up A Static IP Address
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
After another major power failure of 8 hours I finally wrote 2 scripts which I put in init.d: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.
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
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.
-
- Core Developer
- Posts: 459
- Joined: Wed May 26, 2021 9:35 pm
- Has thanked: 59 times
- Been thanked: 383 times
Re: Setting Up A Static IP Address
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
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
Thank you this helped me.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:For DNS, you don't need to Provide more than one but if you do, just leave a space between them.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
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.
-
- Posts: 75
- Joined: Fri Apr 02, 2021 9:11 pm
- Has thanked: 3 times
- Been thanked: 15 times
Re: Setting Up A Static IP Address
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
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
Re: Setting Up A Static IP Address
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
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
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
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]
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: Setting Up A Static IP Address
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
-
- Posts: 157
- Joined: Sun Aug 30, 2020 12:04 am
- Has thanked: 98 times
- Been thanked: 46 times
Re: Setting Up A Static IP Address
Re: Setting Up A Static IP Address
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.
- Attachments
-
- network_ip_static.zip
- (2.43 KiB) Downloaded 492 times
Re: Setting Up A Static IP Address
yoshi41 wrote: ↑Sat Apr 23, 2022 10:29 amI 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
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.
-
- Top Contributor
- Posts: 1441
- Joined: Mon May 25, 2020 7:54 pm
- Has thanked: 496 times
- Been thanked: 467 times
Re: Setting Up A Static IP Address
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"
CRT SCR$ Project - building a collection of high-quality photos of CRT displays
CRT ART Books - retro-gaming books with authentic CRT photos