Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-05-2006, 04:29 PM
|
#1
|
Senior Member
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639
Rep: 
|
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
|
|
|
05-05-2006, 04:45 PM
|
#2
|
Member
Registered: Apr 2006
Location: Pittsburgh
Distribution: Debian Sid AMD64
Posts: 296
Rep:
|
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. 
|
|
|
05-05-2006, 05:28 PM
|
#3
|
LQ Newbie
Registered: Sep 2005
Distribution: Gentoo
Posts: 26
Rep:
|
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
|
|
|
05-05-2006, 05:47 PM
|
#4
|
Senior Member
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639
Original Poster
Rep: 
|
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
|
|
|
05-06-2006, 12:05 AM
|
#5
|
Senior Member
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,639
Original Poster
Rep: 
|
It worked great. Thanks ataraxia.
Brian
|
|
|
05-06-2006, 04:30 PM
|
#6
|
Member
Registered: Nov 2003
Distribution: slackware 15
Posts: 546
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 02:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|