WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: simplest way to establish a static IPADDR for an interface?  (Read 5258 times)

Offline nsqtr

  • Newbie
  • *
  • Posts: 11
simplest way to establish a static IPADDR for an interface?
« on: September 12, 2009, 09:05:17 PM »
I'm using microcore 2.3 and see that the DHCP init script has been changed to ignore already-configured net interfaces.  I want to set eth0 to a static IPADDR and am not sure of the simplest/best way to do so.  Without experimenting, it seems like bootlocal.sh would be too late in the process.  Is there something in /etc/sysconfig that I'm missing?   

thanks for any help


Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: simplest way to establish a static IPADDR for an interface?
« Reply #1 on: September 12, 2009, 09:40:51 PM »
Create a file named eth0.sh
EX:
Code: [Select]
pkill udhcpc
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 192.168.1.1 > /etc/resolv.conf

Then add "/opt/eth0.sh &" to bootlocal.sh
and add "opt/eth0.sh" to .filetool.lst

Offline nsqtr

  • Newbie
  • *
  • Posts: 11
Re: simplest way to establish a static IPADDR for an interface?
« Reply #2 on: September 13, 2009, 12:26:49 AM »
thanks, but I don't want to kill udhcpc. I'm dual-homed and want eth1 to still be a dhcp client, while eth0 has a static ipaddr. So, is an eth0.sh script going to be too late in the boot process to establish a static IPADDR for eth0?

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: simplest way to establish a static IPADDR for an interface?
« Reply #3 on: September 13, 2009, 12:36:32 AM »
Should be fine. You can also use the GUI tool netcardconfig in the control panel and then edit check the eth0.sh that it creates.
10+ Years Contributing to Linux Open Source Projects.

Offline nsqtr

  • Newbie
  • *
  • Posts: 11
Re: simplest way to establish a static IPADDR for an interface?
« Reply #4 on: September 13, 2009, 07:25:44 PM »
I call eth1.sh near the bottom of my bootlocal.sh, which contains:

ifconfig eth1 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255 up
route add -net 10.10.10.0/24 gw 10.10.10.1 eth1

ifconfig eth1 shows me the static assignment.

However, ps -ef shows me that there is an /sbin/udhcpc -b -i eth1 .... etc.etc

process running.  The lease timeout hasn't occurred yet but I wonder if, when the lease expires, the dhcpc daemon will overwrite my static IPADDR for eth1.

Even if it doesn't, I've got a udhcpc process running, which I guess I could kill inside of bootlocal.sh via a spin loop waiting for the udhcpc process to come up.

Any thoughts on a better way?

Offline nsqtr

  • Newbie
  • *
  • Posts: 11
Re: simplest way to establish a static IPADDR for an interface?
« Reply #5 on: September 13, 2009, 08:08:53 PM »
I guess one way of doing it would be to pass the nodhcp boot code and then handle the two interfaces in my bootlocal.sh; i.e., fire up dhcp on eth0 and static route on eth1 overtly

Offline nsqtr

  • Newbie
  • *
  • Posts: 11
Re: simplest way to establish a static IPADDR for an interface?
« Reply #6 on: September 13, 2009, 08:40:10 PM »
perhaps the nodhcp bootcode should be modified to require a list of device names for the nodhcp to apply; e.g.

nodhcp=eth1,ath0

and, in this case, eth0 would be dhcp-enabled.

if the list were empty (i.e. no "=" or thereafter), the nodhcp bootcode would work as now.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: simplest way to establish a static IPADDR for an interface?
« Reply #7 on: September 13, 2009, 10:34:55 PM »
For your special case, I think booting with nohdcp and handling in /opt/bootlocal.sh is more appropriate.
10+ Years Contributing to Linux Open Source Projects.