LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-05-2006, 04:29 PM   #1
BCarey
Senior Member
 
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639

Rep: Reputation: Disabled
Static IP addresses


Hi,

I have a question about static ip addresses. I am installing a laptop for someone, and wireless works fine on networks with dhcp. Unfortunately, at this persons place of work they use static ip addresses. I use Slackware 10.2, and so went in to the /etc/rc.d/rc.inet1.conf file and am able to setup a static ip, but I seem to have to reboot for it to take effect(?). The problem is that I want a static ip only when the computer is at work and the rest of the time I want a dynamic ip. I would ideally be able to switch back and forth without a shutdown.

Is this possible?

Thanks in advance,
Brian
 
Old 05-05-2006, 04:45 PM   #2
ataraxia
Member
 
Registered: Apr 2006
Location: Pittsburgh
Distribution: Debian Sid AMD64
Posts: 296

Rep: Reputation: 30
You can do it with "ifconfig" and "route". To bring up a static IP:
Code:
<kill your DHCP client>
ifconfig eth0 down
ifconfig eth0 inet <your_ip> netmask <your_netmask> broadcast <your_bc> up
route add default gw <your_router>
<edit /etc/resolv.conf for DNS servers>
To switch back to DHCP:
Code:
ifconfig eth0 down
<run your DHCP client>
This is possibly more annoying than just rebooting.
 
Old 05-05-2006, 05:28 PM   #3
Master of Reality
LQ Newbie
 
Registered: Sep 2005
Distribution: Gentoo
Posts: 26
Blog Entries: 1

Rep: Reputation: 15
if you edit the rc.inet1 stuff like you said, you can just run "/etc/rc.d/rc.inet1" (or it may be "/etc/rc.d/rc.inet1 start".

You could copy that script and then modify it to be static, rename the script to something like rc.inet-static and then make it executable so that when the laptop is at work you run that script to start the static IP
 
Old 05-05-2006, 05:47 PM   #4
BCarey
Senior Member
 
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639

Original Poster
Rep: Reputation: Disabled
Thank you both. I will try atraraxia's suggestion, as this is the "kind" of answer I was looking for. I currently use similar commands/scripts to switch between networks, I just couldn't interpret the man page properly to find the inet thing for a static ip address.

Brian
 
Old 05-06-2006, 12:05 AM   #5
BCarey
Senior Member
 
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639

Original Poster
Rep: Reputation: Disabled
It worked great. Thanks ataraxia.

Brian
 
Old 05-06-2006, 04:30 PM   #6
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 15
Posts: 546

Rep: Reputation: 43
I understand you want to be able choosing dhcp or static IP at boot. If yes, it is a very simple task on Slack.
Just create a second config file, let's say /etc/rc.d/rc.inet2.conf and configure it to work with static IP address.
Then create a second block for your kernel in use on your /etc/lilo.conf like

#fisrt block with dhcp
image = /boot/vmlinuz
root = /dev/hda6
label = Linux-dhcp
read-only
#second block with static IP
image = /boot/vmlinuz
root = /dev/hda6
label = Linux-static
append = "static_IP"
read-only

And last, edit your/etc/rc.d/rc.inet1 this way:
when it says

# Get the configuration information from /etc/rc.d/rc.inet1.conf:
. /etc/rc.d/rc.inet1.conf

edit with

if /bin/cat /proc/cmdline | grep -w static_IP 1> /dev/null 2> /dev/null; then
. /etc/rc.d/rc.inet2.conf
else
. /etc/rc.d/rc.inet1.conf
fi

That's all
Hope this helps
Ciao
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto Assign Multiple Static Public IP Addresses under SBC's PPPoE Static Ip system o trekgraham Linux - Networking 8 04-17-2007 10:51 AM
Multiple static IP addresses fr0zen Linux From Scratch 5 11-23-2005 06:47 PM
mixing static and dynamic ip addresses bobwall Linux - Networking 5 07-21-2004 07:47 PM
LAN with static IP addresses and shared internet connection #2 Klas Linux - Networking 10 01-26-2004 10:43 AM
2 static IP addresses on 2 eth cards Zingaro2002 Linux - Networking 8 01-21-2003 12:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration