Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: Adam on July 31, 2013, 07:17:26 PM

Title: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: Adam on July 31, 2013, 07:17:26 PM
Hi all, ifconfig is a temporary solution to set an ip address to linux/unix. I was wondering to make this permanent on Tiny Core Linux so I don't have to re configure it again every time I reboot this machine.

Thanks in advance
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Misalf on July 31, 2013, 07:57:37 PM
In my /opt/bootlocal.sh, I have this entry:
Code: [Select]
/opt/eth0.sh &
My /opt/eth0.sh:
Code: [Select]
#!/bin/sh
pkill udhcpc
ifconfig eth0 192.168.0.3 netmask 255.255.255.0 broadcast 192.168.0.255 up
route add default gw 192.168.0.1
echo nameserver 192.168.0.1 > /etc/resolv.conf

this has been done via gui
ControlPanel -> Network

opt or opt/eth0.sh has to be listed in /opt/.filetool.lst.
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Adam on August 01, 2013, 06:38:16 PM
In my /opt/bootlocal.sh, I have this entry:
Code: [Select]
/opt/eth0.sh &
My /opt/eth0.sh:
Code: [Select]
#!/bin/sh
pkill udhcp
ifconfig eth0 192.168.0.3 netmask 255.255.255.0 broadcast 192.168.0.255 up
route add default gw 192.168.0.1
echo nameserver 192.168.0.1 > /etc/resolv.conf

this has been done via gui
ControlPanel -> Network

opt or opt/eth0.sh has to be listed in /opt/.filetool.lst.

Thanks for your reply. I’ve tried it but didn’t work

Configuration on the following file will be reset once I rebooted the TC

Quote
/opt/bootlocal.sh
/opt/eth0.sh

I did not change /opt/.filetool.lst as /opt is there
Quote
root@box:~# cat /opt/.filetool.lst
opt
home
root@box:~#

Config file before reboot

Quote
root@box:~# cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
/opt/eth0.sh &
root@box:~#

Quote
root@box:~# ls -l /opt/
total 20
-rwxrwxr-x    1 root     staff           66 Aug  1 00:51 bootlocal.sh
-rwxrwxr-x    1 root     staff          272 Mar 15  2011 bootsync.sh
-rw-r--r--    1 root     staff           50 Aug  1 00:54 eth0.sh
-rwxrwxr-x    1 root     staff          613 Dec 26  2012 shutdown.sh
-rw-rw-r--    1 root     staff           31 Dec 15  2012 tcemirror
root@box:~#

Quote
root@box:~# cat /opt/eth0.sh
#!/bin/sh
pkill udhcp
ifconfig eth0 192.168.10.15

root@box:~#

Config file after reboot

Quote
root@box:~# cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
root@box:~#

Quote
root@box:~# ls -l /opt/
total 16
-rwxrwxr-x    1 root     staff           51 Mar  4  2010 bootlocal.sh
-rwxrwxr-x    1 root     staff          272 Mar 15  2011 bootsync.sh
-rwxrwxr-x    1 root     staff          613 Dec 26  2012 shutdown.sh
-rw-rw-r--    1 root     staff           31 Dec 15  2012 tcemirror
root@box:~#
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Rich on August 01, 2013, 09:01:04 PM
Hi Adam
You need to run a backup:
Code: [Select]
filetool.sh -b
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Adam on August 02, 2013, 09:45:45 PM
Hi Adam
You need to run a backup:
Code: [Select]
filetool.sh -b

Thanks Rich. I've run the backup and after reboot, all the config are still there.

BACKUP CONFIG
Code: [Select]
root@box:/# filetool.sh -b
Backing up files to /mnt/sda1/tce/mydata.tgzDone.
root@box:/#

VERIFY CONFIG AFTER REBOOT
Code: [Select]
tc@box:~$ sudo su
root@box:~# cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
/opt/eth0.sh &
root@box:~#
root@box:~# cat /opt/eth0.sh
#!/bin/sh
pkill udhcp
ifconfig eth0 192.168.10.15
root@box:~#

Unfortunately, instead of getting fix ip 192.168.10.15, I’m still getting dhcp ip 192.168.10.101.

VERIFY CURRENT IP ADDRESS
Code: [Select]
root@box:~# ifconfig | grep dd
eth0      Link encap:Ethernet  HWaddr 08:00:27:6C:E7:79
          inet addr:192.168.10.101  Bcast:192.168.10.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0
root@box:~#
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: roberts on August 02, 2013, 11:28:22 PM
To skip the initial dhcp request at boot use the boot code of nodhcp

-rw-r--r--    1 root     staff           50 Aug  1 00:54 eth0.sh
Second be sure /opt/eth0.sh is made executable.
-rwxr-xr-x    1 root     staff           50 Aug  1 00:54 eth0.sh
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Rich on August 03, 2013, 11:18:48 AM
Hi Adam
Quote
pkill udhcp
Try:
Code: [Select]
pkill udhcpc
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Rich on August 03, 2013, 11:22:47 AM
Hi Misalf
Read my previous post. You might want to double check your system and make sure your syntax is correct.
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Misalf on August 03, 2013, 01:19:26 PM
Thanks Rich.
(I've edited my post)
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Adam on August 12, 2013, 01:51:07 AM
To skip the initial dhcp request at boot use the boot code of nodhcp

-rw-r--r--    1 root     staff           50 Aug  1 00:54 eth0.sh
Second be sure /opt/eth0.sh is made executable.
-rwxr-xr-x    1 root     staff           50 Aug  1 00:54 eth0.sh

Thanks Roberts for your reply. /opt/eth0.sh is executable now.

Code: [Select]
root@box:/# ls -l /opt/eth0.sh
-rw-r--r--    1 root     staff           50 Aug  1 02:32 /opt/eth0.sh
root@box:/#

root@box:/# chmod a+x /opt/eth0.sh
root@box:/#

root@box:/# ls -l /opt/eth0.sh
-rwxr-xr-x    1 root     staff           50 Aug  1 02:32 /opt/eth0.sh
root@box:/#

I’ve backup this config using “filetool.sh –b” and rebooted the box. Unfortunately it doesn’t work.
Quick question, may I know how to use the boot code of nodhcp?
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Adam on August 12, 2013, 02:02:04 AM
I’ve noticed something after reboot. There are two situations now:

1.   I’ll get DHCP ip if I did not login to root
2.   I’ll get static ip if I login to root immediately

Code: [Select]
sudo su
Title: Re: How to set permanent ip address in Tiny Core Linux?
Post by: Rich on August 12, 2013, 10:06:26 AM
Hi Adam
Reread reply #6 and edit your  /opt/eth0.sh  accordingly. This is not high school, spelling counts.
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: jatinkhatri on October 22, 2013, 10:38:25 AM
well you need to do the following hack

just add following line in .xsession  in ~/tc ( it works for me ...)

sleep 5

sudo ifconfig eth0 xx.xx.xx.xx netmask xxx.xxx.xxx.xxx broadcast xxx.xxx.xxx.xxx.xxx up
sudo route add gw xx.xx.xx.xx
sudo echo 8.8.8.8 > /etc/resolv.conf
other  command if needed


( where "x" is  IP address you want to set  )
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: gerald_clark on October 22, 2013, 01:04:47 PM
No, you do not.
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: coreplayer2 on October 22, 2013, 01:23:54 PM
Am not sure but wouldn't you use ControlPanel > Network to set static IP addresses??

Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: Lee on October 22, 2013, 01:42:19 PM
The control panel network applet essentially just does the three sudo commands similar to those given in reply #12.

Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: tinypoodle on October 22, 2013, 05:58:10 PM
A command in .xsession would be executed on every start of X11.
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: gerald_clark on October 22, 2013, 06:09:22 PM
.xsession is the wrong place. It is for  X and only X.
Putting configuration scripts in the wrong place will only cause support issues later when you can't figure out why the
proper config script in /opt does not seem to work.
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: jatinkhatri on October 23, 2013, 01:02:45 AM
Am not sure but wouldn't you use ControlPanel > Network to set static IP addresses??

on every reboot, eth0 gets ip from dhcp server, if you set Static IP  from control-panel, it gates flushed on reboot. You have to manually set IP address after restart.
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: jatinkhatri on October 23, 2013, 01:05:35 AM
No, you do not.

it works for me .... really ...I do not need to go to each thin-client to change the IP address to the static which I want to assign to that machine  , I've added that command to .xsession it works like anything,
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: coreplayer2 on October 23, 2013, 03:21:03 AM
Thanks Gerald, I got it now.. 

write a script to set static IP, place it in /opt  and start it from an entry in bootlocal.sh on each boot

 8)
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: tinypoodle on October 23, 2013, 02:48:48 PM
Am not sure but wouldn't you use ControlPanel > Network to set static IP addresses??

on every reboot, eth0 gets ip from dhcp server, if you set Static IP  from control-panel, it gates flushed on reboot. You have to manually set IP address after restart.

No you don't, but you have to use boot code "nodhcp".
Title: Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
Post by: tinypoodle on October 23, 2013, 02:50:59 PM
No, you do not.

it works for me .... really ...I do not need to go to each thin-client to change the IP address to the static which I want to assign to that machine  , I've added that command to .xsession it works like anything,

Have you tried to see what happens when you start X for the second time?