Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started 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
-
In my /opt/bootlocal.sh, I have this entry:
/opt/eth0.sh &
My /opt/eth0.sh:
#!/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.
-
In my /opt/bootlocal.sh, I have this entry:
/opt/eth0.sh &
My /opt/eth0.sh:
#!/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
/opt/bootlocal.sh
/opt/eth0.sh
I did not change /opt/.filetool.lst as /opt is there
root@box:~# cat /opt/.filetool.lst
opt
home
root@box:~#
Config file before reboot
root@box:~# cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
/opt/eth0.sh &
root@box:~#
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:~#
root@box:~# cat /opt/eth0.sh
#!/bin/sh
pkill udhcp
ifconfig eth0 192.168.10.15
root@box:~#
Config file after reboot
root@box:~# cat /opt/bootlocal.sh
#!/bin/sh
# put other system startup commands here
root@box:~#
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:~#
-
Hi Adam
You need to run a backup:
filetool.sh -b
-
Hi Adam
You need to run a backup:
filetool.sh -b
Thanks Rich. I've run the backup and after reboot, all the config are still there.
BACKUP CONFIG
root@box:/# filetool.sh -b
Backing up files to /mnt/sda1/tce/mydata.tgzDone.
root@box:/#
VERIFY CONFIG AFTER REBOOT
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
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:~#
-
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
-
Hi Adam
pkill udhcp
Try:
pkill udhcpc
-
Hi Misalf
Read my previous post. You might want to double check your system and make sure your syntax is correct.
-
Thanks Rich.
(I've edited my post)
-
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.
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?
-
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
sudo su
-
Hi Adam
Reread reply #6 and edit your /opt/eth0.sh accordingly. This is not high school, spelling counts.
-
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 )
-
No, you do not.
-
Am not sure but wouldn't you use ControlPanel > Network to set static IP addresses??
-
The control panel network applet essentially just does the three sudo commands similar to those given in reply #12.
-
A command in .xsession would be executed on every start of X11.
-
.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.
-
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 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,
-
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)
-
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".
-
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?