Android IP change on NAS - need help finding it again
#1
Hi guys,

I'm not sure this is a specific android question and I'm sure this has been covered elsewhere, but I can't find it. So bear with me...

I changed my NAS from dynamic IP to a static one. Of course the IP address differs now (well, it differed before as well as it changed since it was dynamic). And now Kodi can't play my films.

I'm running Kodi on and android box, Minix Neo and I can't find where to change the IP address for my source.

Can anyone pls tell med where to change?

Thanks.
Reply
#2
There are theoretical ways around it, but you will most likely find yourself in a position where you need to delete your original source, clean library, then re-add the NAS w/ the new IP as a source again.
Reply
#3
You'll probably need to remove and re-add your source for the NAS and then clean your library (to remove the links to the films via the old IP address) and then rescan to put the new ones in on the correct IP address.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#4
Bummer. What if I change the IP address for the NAS back to the one that can be found by Kodi? And where do I find the right address (I've looked for it in Kodi)?
Reply
#5
As long as the IP address in the library matches the one on the network then it'll be fine.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#6
Path subs (wiki) might work here.
Reply
#7
You don't need to change anything, that's what name resolution is all about.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#8
That would depend if the source (and so the links in the library) is set up by name or IP address though?

Browsing source (NFS) on my network always finds by IP address rather than name...
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#9
(2016-01-18, 20:59)StaLin Wrote: Bummer. What if I change the IP address for the NAS back to the one that can be found by Kodi? And where do I find the right address (I've looked for it in Kodi)?

Odds are your router wont let you do it
Maybe if you choose the original ip addy as the new static ip, hoping that ip has not been re-issued, it might work

Does your nas support ddns service like synology does? That would be a perfect way around it
Reply
#10
Thanks for your answers. I just ended up deleting the source and redoing it.
Reply
#11
Well, there is a way to change IPs without re-establishing all your sources, but it's not for the faint of heart.

I'm posting here the process that worked for me, in case it helps anyone else.
My setup uses OpenElec, so some small aspects might differ from what you have. Also my machines are all Linux.

Some of my IPs: (replace with your own)
  • my Kodi machine: 192.186.1.4
  • old media server IP: 192.186.2.222
  • new media server IP: 192.186.1.111

Note: I didn't want to have to do this process again and again, every time IP addresses change, so I decided to use a DNS name for the new media server. I decided to use "diskstation" as the DNS name. If you'd like to do this too, then think of a one-word name and see the DNS Note in step 1 below.

So here goes...


STEP 1. ssh into your Kodi server:
If you've never done this before, you might have to google to find the right username/password for your setup. In my case it was root/openelec.

DNS Note:
If you want to use a DNS name instead of an IP address for your file server (which will save you from doing this process every time you renumber) then carry out these steps on the Kodi machine (as root):
  1. Edit your DNS hosts file. This is usually /storage/.config/hosts.conf, but can sometimes be /etc/hosts directly. In my case it was the former:
    Code:
    sudo nano /storage/.config/hosts.conf
  2. Add a new line consisting of the new IP address, then some whitespace (spaces or tab) then the hostname. Mine looked like this:
    Quote:192.168.1.111 diskstation
  3. Save the file: Ctrl-O, and then exit nano Ctrl-X.
  4. If your edits were made in /storage/.config/hosts.conf, then reboot:
    Code:
    sudo reboot now
    (this will close your ssh session)
  5. After Kodi machine has restarted, ssh into it again:
  6. Then check that your DNS name is active:
    Code:
    ping diskstation
    You should get a result similar to this:
    Quote:# ping diskstation
    PING diskstation (192.168.1.111): 56 data bytes
    64 bytes from 192.186.1.111: seq=0 ttl=64 time=0.163 ms
    64 bytes from 192.186.1.111: seq=1 ttl=64 time=0.171 ms
    64 bytes from 192.186.1.111: seq=2 ttl=64 time=0.163 ms
    [...]
  7. If that worked then in the following steps you can use "diskstation" (or whatever name you chose) instead of the new IP.
  8. Next time you renumber your media server, you can ignore all the following steps, and instead edit the line you just added same file (eg: /storage/.config/hosts.conf), changing the IP address.


STEP 2. Go into your kodi folder:
(I found this page very helpful in working out where this is)
Code:
cd /storage/.kodi/userdata/


STEP 3. Find occurrences of the old IP:
Code:
grep -rc "192\.168\.2\.222" *
This will take a while. It outputs the names of the files that contain the old IP address, along with the number of lines in which it was found in each file. In my case, the following files were found:
Quote:Database/ViewModes6.db:4
Database/MyVideos90.db:12100
Database/Textures13.db:6236
sources.xml:3
So sources.xml is a text file, great! That can be edited in place. Unfortunately the others are all SQLite databases. So...


STEP 4. Copy files to your local machine:
I preferred to work on my own machine, since I have a GUI there. There are SQLite command-line tools, but I wanted to see chunks of data as well, in order to confirm that I was doing things right. So I copied all the files to my local machine to work on them.

On my local machine:
Code:
#create a folder to work in
mkdir /tmp/kodi_files
cd /tmp/kodi_files
#copy all the files that contained the old IP address
scp [email protected]:/storage/.kodi/userdata/Database/ViewModes6.db .
scp [email protected]:/storage/.kodi/userdata/Database/MyVideos90.db .
scp [email protected]:/storage/.kodi/userdata/Database/Textures13.db .
Note: don't just copy the above if your set of files was different to mine. Adjust according to the files you found.


STEP 5. Load up your SQLite database manager:
I didn't have one, but found SQLiteMan in the Ubuntu Software Center and installed it.
It could also be installed through command line, like this
Code:
sudo apt-get install sqliteman
Once installed, run it, and open up one of the above files. eg: ViewModes6.db

Next we have to find which fields, of which tables, contain data that needs to be updated. This is a bit tedious so bear with me.


5. Dump the database:
I found that the easiest way to determine which fields needed updating was to dump the entire database to a .sql file. This creates a plain text file with a whole bunch of SQL INSERT statements that would re-create the same database. It is handy for us because it identifies the tables and fields we need to work on. I first thought there might be a better way to search the contents of all fields in all tables, but I couldn't find one. If anyone knows a better way, please advise.
In Sqliteman, the sequence of commands (starting from main menu) was:
Database > Dump Database
Let's call the file by the same name, with a different suffix, eg: ViewModes6.sql


STEP 6. Find occurrences of the old IP:
Back in the command-line prompt, find the first few occurrences of the old IP address:
Code:
grep "192\.168\.2\.222" ViewModes6.sql | head -10
This shows the first 10 lines that contained the old IP address. Each line starts with something like this:
Quote:INSERT INTO "view" VALUES(7,10025,'nfs://192.186.2.222/volume1/video/movies/' ...
This tells us what we need to know:
  • the table is called "view" (may be different each time)
  • the field containing the old IP is the 3rd field in the list of values (would be different each time)


STEP 7. Replace occurrences of the old IP in SQL:
  1. Back in SQLiteMan, double-click the "view" table (or whatever table was found) to open it. You should see rows of data on the bottom right, and space to write queries on top right.
  2. Click "Columns" on the left to open the list of fields. Get the field name by counting to the 3rd field. In this case it was called "path":
    Image
  3. Create an UPDATE statement to replace all occurrences of the old IP with the new one, eg:
    Code:
    UPDATE view SET path = REPLACE(path, '192.168.2.222', '192.168.1.111');
    Note: if you chose to use a DNS name, instead of an IP, then use the DNS name in your query instead. It might look like this:
    Code:
    UPDATE view SET path = REPLACE(path, '192.168.2.222', 'diskstation');
  4. Enter that statement in the query pane, and run it by clicking the single green arrow:
    Image
  5. If no errors, then occurrences of the old IP in the path field of the view table have now been replaced, well done!
  6. Now go back to step 5 and repeat. You will find different tables and fields each time. I think I only needed to run 4 updates - it didn't take long.
  7. When the "grep" command in step 6 finds nothing, then you are done replacing, and can proceed to the next step.


STEP 8. Backup the files that are going to be changed:
On the Kodi machine (in your ssh session) make backups of all the affected files. Mine were:
Code:
cp /storage/.kodi/userdata/Database/MyVideos90.db /storage/.kodi/userdata/Database/MyVideos90.db.BAK
cp /storage/.kodi/userdata/Database/Textures13.db /storage/.kodi/userdata/Database/Textures13.db.BAK
cp /storage/.kodi/userdata/Database/ViewModes6.db /storage/.kodi/userdata/Database/ViewModes6.db.BAK
cp /storage/.kodi/userdata/sources.xml /storage/.kodi/userdata/sources.xml.BAK
(your files may be different, make sure you back them all up)


STEP 9. Copy your updated files back to the Kodi machine:
After checking the Kodi isn't actually busy reindexing or otherwise working with its database go back to you local machine then go ahead and copy those updated files back to Kodi.
In my case, these copy commands were:
Code:
scp MyVideos90.db  [email protected]:/storage/.kodi/userdata/Database/MyVideos90.db
Quote:MyVideos90.db 100% 17MB 16.5MB/s 00:01

Code:
scp Textures13.db [email protected]:/storage/.kodi/userdata/Database/Textures13.db
Quote:Textures13.db 100% 6560KB 6.4MB/s 00:01
Code:
scp ViewModes6.db [email protected]:/storage/.kodi/userdata/Database/ViewModes6.db
Quote:ViewModes6.db 100% 20KB 20.0KB/s 00:00
Don't forget we still have to edit sources.xml:
Code:
nano /storage/.kodi/userdata/sources.xml
Change all occurrences of the old IP into the new IP (or DNS name). In my case there were 3 occurrences that had to be edited. Then save (Ctrl-O) and exit (Ctrl-X) when done.
Last step, reboot Kodi:
Code:
sudo reboot now


And you're done!

For me, this worked, and after the last reboot Kodi could find everything where it was supposed to be.
Hope it works for you too!

P.S. This entire process could totally be scripted, maybe someone adventurous wants to give that a try? Actually, it should really be built into Kodi...

G.
Reply
#12
Wow. Pathsubs for the win!
Reply
#13
Having hit issues with the lengthy instructions below (I couldn't immediately get access to the Shield TV storage), so I did a little experimentation and found a less involved way of updating the library to account for a change of NAS IP address.

After changing your NAS IP address, and given the NAS changed from 192.168.f.f to 192.168.t.t (replace with your IP addresses!)

1) Export Library from Kodi...
In Kodi (v19), go to Settings / Media / Library / Export Library - and supply a location that will persist after the NAS IP change, and choose 'Single File' option when prompted.

2) Edit library XML File...
From a PC, establish a share to the export location
In Windows 10, File Explorer, Right-click 'This PC', select 'Map Network Drive' - and map, say, Z: to \\192.168.b.b  and 'Browse' to the export drive.
In File Explorer find the Find the directory containing the export. For Kodi v19 it will be something like  'kodi_videodb_2021-12-11'.
Now find the file : 'videodb.xml'.
Using a text editor (e.g. Notepad++, or Notepad should be okay) find and replace all '192.168.f.f'  with '192.168.t.t'  (view the file and make sure the replace worked)
Save the file.

3) Import library XML file back into Kodi...
In Kodi, go back into Settings / Library, but this time select Import Library, and import the 'videodb.xml' just edited.
After the import also do a 'Clean Library' otherwise there will be two of everything. (Doing Clean Library before the Import is probably neater, but this is the way I did it, and it worked fine.)

Content in Movies / TV etc. should now all point to the new NAS. The 'In progress' Movies etc. on the initial Kodi screen unfortunately retain the old address. Newly watch content will appear correctly though.
Reply
#14
I missed a step at the beginning...

0) In Kodi, edit the old IP address references - to the new IP address - in the sources set up in Settings / Media / Videos (etc.) Right click / long press on sources, then 'Edit Source'. On its own, this step won't fix the problem, but after following the other steps provided the source will point to the new IP address.
Reply
#15
(2021-12-11, 19:05)steve_k Wrote: I couldn't immediately get access to the Shield TV storage

There is a way to enable the Shield's SMB server, after that you can access all its files including all of Kodi's files.
You can find them in: smb://<nvidiashieldurl>/internal/Android/data/org.xbmc.kodi/files/.kodi/userdata
Reply

Logout Mark Read Team Forum Stats Members Help
IP change on NAS - need help finding it again0