WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] How to set permanent ip address in Tiny Core Linux?  (Read 38481 times)

Offline Adam

  • Full Member
  • ***
  • Posts: 121
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
« Last Edit: August 18, 2013, 02:06:43 AM by Adam »

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #1 on: July 31, 2013, 04: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.
« Last Edit: August 03, 2013, 10:17:13 AM by Misalf »
Download a copy and keep it handy: Core book ;)

Offline Adam

  • Full Member
  • ***
  • Posts: 121
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #2 on: August 01, 2013, 03: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:~#
« Last Edit: August 01, 2013, 03:41:46 PM by Adam »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #3 on: August 01, 2013, 06:01:04 PM »
Hi Adam
You need to run a backup:
Code: [Select]
filetool.sh -b

Offline Adam

  • Full Member
  • ***
  • Posts: 121
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #4 on: August 02, 2013, 06: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:~#

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #5 on: August 02, 2013, 08: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
10+ Years Contributing to Linux Open Source Projects.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #6 on: August 03, 2013, 08:18:48 AM »
Hi Adam
Quote
pkill udhcp
Try:
Code: [Select]
pkill udhcpc

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #7 on: August 03, 2013, 08:22:47 AM »
Hi Misalf
Read my previous post. You might want to double check your system and make sure your syntax is correct.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #8 on: August 03, 2013, 10:19:26 AM »
Thanks Rich.
(I've edited my post)
Download a copy and keep it handy: Core book ;)

Offline Adam

  • Full Member
  • ***
  • Posts: 121
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #9 on: August 11, 2013, 10:51:07 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

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?

Offline Adam

  • Full Member
  • ***
  • Posts: 121
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #10 on: August 11, 2013, 11:02:04 PM »
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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: How to set permanent ip address in Tiny Core Linux?
« Reply #11 on: August 12, 2013, 07:06:26 AM »
Hi Adam
Reread reply #6 and edit your  /opt/eth0.sh  accordingly. This is not high school, spelling counts.

Offline jatinkhatri

  • Newbie
  • *
  • Posts: 3
Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
« Reply #12 on: October 22, 2013, 07: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  )
« Last Edit: October 22, 2013, 08:13:18 AM by jatinkhatri »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
« Reply #13 on: October 22, 2013, 10:04:47 AM »
No, you do not.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: [SOLVED] How to set permanent ip address in Tiny Core Linux?
« Reply #14 on: October 22, 2013, 10:23:54 AM »
Am not sure but wouldn't you use ControlPanel > Network to set static IP addresses??

« Last Edit: October 22, 2013, 10:52:21 AM by coreplayer2 »