Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How can I set up a static IP? ISP needs DHCP.
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Thu Aug 05, 2004 9:10 am    Post subject: How can I set up a static IP? ISP needs DHCP. Reply with quote

Hi I am a bit of a networking n00b. Anyhoo, for reasons of convienience I want to change my network configuratiion and give my main PC a fixed IP on my network. Basically I want that IP to be 192.168.1.100 - which is within a range of about 100 static IPs I have defined on my router (with about 250 above this reserved for DHCP).

Well anyway the thing is, I am a little nervous that I could mess up my networking completely if I get it wrong, especially seeing as DHCP is working great. I am also a little confused by some of the questions netsetup asks. I mean, what is the broadcast address? What exactly should I put here?

The problem is that my ISP expects me to connect via DHCP - so so long as I can connect externally to my ISP and still have an internal static ip for my PC - that is exactly what I would like to do.

Basically my router has an address of 192.168.1.1

I have a predefined range of static IPs I can use on my lan which is goes from 192.168.1.2 to 192.168.1.110. I have a number of applications which in order to function correctly must have the appropriate ports open - and so I have to be able to define a static IP for them if I am to get them to work.

Currently they all expect the PC on the lan to have an address of 192.168.1.100.

How can I make sure I can give my Gentoo install the correct static IP on my lan without loosing my internet connection?


Last edited by raid517 on Thu Aug 05, 2004 10:50 am; edited 1 time in total
Back to top
View user's profile Send private message
snuck
n00b
n00b


Joined: 26 Jun 2003
Posts: 40
Location: to your left

PostPosted: Thu Aug 05, 2004 9:54 am    Post subject: Reply with quote

I'm not exactly a networking guru, but if I'm wrong I'm sure someone will correct me...

To give a box on your lan a static IP add this to your dhcpd.conf on your router:

host host_name_Here {
hardware ethernet mac_address_here;
fixed-address ip_address_you_want_it_to_have_here;
}

To find out the mac address do (as root)

#ifconfig

on the box you want to give the static address.

HTH

snuck.
_________________
Do you wish you got insulted more? Well here's your chance...
Back to top
View user's profile Send private message
Nossie
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 181

PostPosted: Thu Aug 05, 2004 10:24 am    Post subject: Reply with quote

Sorry, but I don't completely understand your question.

The router you are talking about, is it a Gentoo box, or a 'hardware' router / modem ?

Your internal network is 192.168.1.0 i assume with netmask 255.255.255.0 (this can also be written as 192.168.1.0/24) If this is the case your broadcast address will be 192.168.1.255

As long as you stay in the range of 192.168.1.2 to 192.168.1.254 with netmask 255.255.255.0 you will be ok concerning your connectivity to the router (as long as the ip address you set on your computer doesn't conflict with (is the same as) another computer).

As I understand it, your router is a dhcp server, ad it gives ip numbers from .110 to .254 If this is true, you can manually set you IP to anything lower than 192.168.110 (except for .1 of course)

I hope this makes some sense to you...

greetz,
Nossie
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Thu Aug 05, 2004 11:00 am    Post subject: Reply with quote

Yes it is a router. (Well it's a combo router and adsl modem in one external box). And Nossie what you said makes perfect sense to me. And you got my setup exactly right too.

However I did the net-setup thing and I entered the values you suggested, giving myself an IP of 192.168.1.100 and so on. In actual fact, netsetup guessed the rest giving me a broadcast address of 192.168.1.255 a network mask of 255.255.222.0 and I filled in the gateway address for eth0 as 192.168.1.1 - which I assume is the address of my router. But when I did this I lost my internet connection.

Is there something I'm missing here?

GJ
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Thu Aug 05, 2004 11:12 am    Post subject: Reply with quote

Lol, never mind. Maybe I should try rebooting once in a while. It's been a long time - but anyhoo that seemed to resolve it.

Just one thing though, does this mean that I actually need DHCP on my Linux box any more, or can I disable it? I only ask as it really slows down boot quite a lot as DHCP looks for a server and then eventually gives up as it isn't being used.

If so how can I safely do this? I mean how can I do this in a way that makes it easy to renable it if I need to?

GJ
Back to top
View user's profile Send private message
Nossie
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 181

PostPosted: Fri Aug 06, 2004 9:36 am    Post subject: Reply with quote

Hi,

Yes you can disable the dhcp client on your linux box. Now you have manually cofigured your ip, the dhcp client doesn't do anything anymore (except lag your boot time).

Nossie
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Fri Aug 06, 2004 10:19 am    Post subject: Reply with quote

Erm.. so how do I do that? And more importantly, how do I test that I have got the static IP address that I wanted (i.e.192.168.1.100)? I ask as I have already configure my system for a static IP, which *appears* to be working. But right now I have no way to confirm this.

Also what other software is there on a fairly raw gentoo install that I might need to consider if I wanted to gurantee that I left ports open for my favorite applications in Linux? (I speak specifically in this instance of Xmule). Because right now I'm suspicious that although I have configured a static IP and have opened the appropriate ports on my router that Xmule is still complaining it can't reach my ports. So it seems that either my static IP isn't running correctly yet, or something else I'm not familiar with is blocking the ports.

Has any one got any possible hints?

GJ
Back to top
View user's profile Send private message
ronnie
n00b
n00b


Joined: 21 Jul 2004
Posts: 66

PostPosted: Fri Aug 06, 2004 11:07 am    Post subject: Reply with quote

Actually, to switch from dhcp to static, you should edit /etc/conf.d/net and
1. comment out the line iface_eth0="dhcp" so it reads
Code:
#iface_eth0="dhcp"

2. uncomment and change values in the line starting with #iface_eth0=" so it reads something like this:
Code:
iface_eth0="192.168.1.100 broadcast 192.168.1.255 netmask 255.255.255.0"

3. fix default route (the last line in the file) to:
Code:
gateway="eth0/192.168.1.1"

On your next boot dhcp client will not run at all. /etc/init.d/net.eth0 restart makes changes without reboot. To display network info, run (as root):
Code:
# ifconfig eth0

All examples presumes you are using eth0 as your network interface.
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Fri Aug 06, 2004 9:23 pm    Post subject: Reply with quote

Thanks, that worked great and into the bargain i learned some very neat stuff about networking too. I now have a super high Xmule id (meaning my ports can be raeched) and can now choose which servers I want to connect to at will.

Thanks again.

GJ
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 1:08 am    Post subject: Reply with quote

There is only one thing though... DHCP came back after I rebooted even though I followed your instructions to the letter. Now I have lost the high ID in Xmule I had before and my ports are unreachable.

How do i prevent DHCP from starting during boot at all?

It is proving to be somewhat troublesome to get rid of it.

GJ
Back to top
View user's profile Send private message
Yoda_Oz
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 143
Location: Southampton, UK

PostPosted: Sat Aug 07, 2004 4:28 am    Post subject: Reply with quote

im no networking guru or linux guru either, but like what ronnie said, if you disable anything that refers to dhcp in your /etc/conf.d.net file then dhcp shouldnt start at boot. have you noticed that your eth0 card gets initialised first and then dhcp starts? this is because when the interface net.eth0 is initialised it searches through the /etc/conf.d/net file for the properties to give that interface then its loads them. if it finds that it needs to load dhcp then it will load dhcp.

people... please correct me if im wrong as im trying to learn too!

i did learn something today about xmule! thanks raid517 because i didnt know why i was always connected as a lowID, it was because i had dhcp set and not a static ip. now i have a static ip and i have a highID!!! yay!!!
_________________
DELL INSPIRON 5150 (2004)
Intel P4 HT 3.06
512Mb
nVidia GeForce FX Go5200 64Mb
Actiontec 802CAT1 Wireless PCMCIA
Linux Kernel vmlinuz-2.6.10-2-386
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 6:23 am    Post subject: Reply with quote

Well I am only very pleased that in the process of helping myself I was able to help someone else too. :)

However despite double checking my /etc/conf.d/net file I making sure that everything with regard to dhcp is commented out, dhcp is still loading and controlling my eth0 after a reboot.

I can manually follow the instructions here and can obtain a static IP, but this goes away after a reboot and dhcp takes over again.

Here is the layout of my /etc/conf.d/net file:

Code:
# /etc/conf.d/net:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface
#
#iface_eth0="192.168.0.2 broadcast 192.168.0.255 netmask 255.255.255.0"
#iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"
# For passing options to dhcpcd use dhcpcd_eth?
#
iface_eth0="192.168.1.100 broadcast 192.168.1.255 netmask 255.255.255.0"
#dhcpcd_eth0="..."

# For adding aliases to a interface
#
#alias_eth0="192.168.0.3 192.168.0.4"

# NB:  The next is only used for aliases.
#
# To add a custom netmask/broadcast address to created aliases,
# uncomment and change accordingly.  Leave commented to assign
# defaults for that interface.
#
#broadcast_eth0="192.168.0.255 192.168.0.255"
#netmask_eth0="255.255.255.0 255.255.255.0"


# For setting the default gateway
#
gateway="eth0/192.168.1.1"


Which is accurate as far as I'm aware.

So the question is, how on earth is this possible?

I ran the netsetup software too, but again dhcp refused to go away.

Has anybody got any suggestions?
Back to top
View user's profile Send private message
Yoda_Oz
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 143
Location: Southampton, UK

PostPosted: Sat Aug 07, 2004 6:32 am    Post subject: Reply with quote

im not sure which config file it would be in (somebody help me) but is the program/script 'dhcpcd' loaded anywhere in the boot process?

for eg. it would be somewhere saying:
Code:

dhcpcd ethx


perhaps you could try:
Code:

rc-update -s

that will show what scripts are loaded...

haha, i dont know the exact code as im very new to linux, but try something similar to that maybe. i dont take responsibility for destroying your computer though...hehe/
_________________
DELL INSPIRON 5150 (2004)
Intel P4 HT 3.06
512Mb
nVidia GeForce FX Go5200 64Mb
Actiontec 802CAT1 Wireless PCMCIA
Linux Kernel vmlinuz-2.6.10-2-386
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 6:38 am    Post subject: Reply with quote

Well this is what we have:

Code:
/home/raid516 ;) rc-update -s
           alsasound | boot
                apmd |
               aumix |
          autoconfig |      default
            bootmisc | boot
          bootsplash |      default
             checkfs | boot
           checkroot | boot
               clock | boot
         consolefont | boot
         crypto-loop |
               cupsd |
          domainname |
              esound |
                famd |      default
              freevo |
            gkrellmd |
                 gpm |
              hdparm |
            hostname | boot
             hotplug |
             keymaps | boot
              kismet |
               lircd |
                lisa |
               local |      default nonetwork
          localmount | boot
             metalog | boot default
             modules | boot
               mysql |      default
         mythbackend |
           neostrada |
             nessusd |
            net.eth0 |
              net.lo | boot
            net.ppp0 |
            netmount |      default
                nscd |
             numlock |
             portmap |
             reslisa |
           rmnologin | boot
            rp-pppoe |
              rsyncd |
               samba |
              serial | boot
          speedtouch |
              splash |      default
                sshd |
             urandom | boot
              vmware |      default
             winbind |
                 xdm |      default
                 xfs |


Am I missing it? I can't see it there? Maybe I should try to find the dhcp script and just rename it. But that is a bit of a hack really as I would prefer to disable it properly so I can renable it if the occasion ever demands it.

GJ
Back to top
View user's profile Send private message
Yoda_Oz
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 143
Location: Southampton, UK

PostPosted: Sat Aug 07, 2004 7:05 am    Post subject: Reply with quote

well, we've eliminated the dhcpcd thing then...

something is calling that script at boot. i cant tell you what that is though. i suggest you ask around how to disable dhcp at boot because thats what seems to be the prob... sorry i couldnt help... but dont give up!!!

reply post when you work it out so i can learn too mate.
_________________
DELL INSPIRON 5150 (2004)
Intel P4 HT 3.06
512Mb
nVidia GeForce FX Go5200 64Mb
Actiontec 802CAT1 Wireless PCMCIA
Linux Kernel vmlinuz-2.6.10-2-386
Back to top
View user's profile Send private message
tapted
Tux's lil' helper
Tux's lil' helper


Joined: 02 Dec 2003
Posts: 122
Location: Sydney, Australia

PostPosted: Sat Aug 07, 2004 7:12 am    Post subject: Reply with quote

Check out http://gentoo-wiki.com/HOWTO_setup_a_home-server. Make sure you skim through the whole thing before doing stuff though. It got me going in no time ;-)
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 7:14 am    Post subject: Reply with quote

Well I'm completely stuck too. Surely we have some networking gurus round here who know what's going on?

I tried as I said just renaming the dhcp binary, but this caused me to loose net connectivity completely on the net boot. I guess this is because whatever script is running is telling the system it should expect dhcp.

Thanks for trying anyway - but I sure hope someone else will pick this up. :(

GJ
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 7:22 am    Post subject: Reply with quote

tapted wrote:
Check out http://gentoo-wiki.com/HOWTO_setup_a_home-server. Make sure you skim through the whole thing before doing stuff though. It got me going in no time ;-)


Thanks for the pointer. Unfortunately the problem is that I'm not trying to start a server, I'm trying to stop one, specifically DHCP.

I read through that tutorial and it touches on much of what has been said here.

Unfortunately the DHCP section only discusses starting DHCP and not how to switch from DHCP to static networking. There is no mention that I can see there how to do this.

Again, thanks for the input. Everyone's opinions are welcome.

GJ
Back to top
View user's profile Send private message
nobspangle
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1318
Location: Manchester, UK

PostPosted: Sat Aug 07, 2004 7:32 am    Post subject: Reply with quote

It doesn't look like your net script is set to run
Code:
rc-update add net.eth0 default

will add it to the default runlevel
Back to top
View user's profile Send private message
tapted
Tux's lil' helper
Tux's lil' helper


Joined: 02 Dec 2003
Posts: 122
Location: Sydney, Australia

PostPosted: Sat Aug 07, 2004 8:45 am    Post subject: Reply with quote

raid517 wrote:

Unfortunately the DHCP section only discusses starting DHCP and not how to switch from DHCP to static networking. There is no mention that I can see there how to do this.


The distinction is moot.

If you use dnsmasq, it will first try to assign IP addresses found in your /etc/hosts file (based on the hostname that each computer tells the dhcp server it is -- look at /var/log/messages to find out what this is). This is what I've done myself for my intranet.

Alternatively, you can edit

/etc/dnsmasq.conf

and assign IP addresses based on MAC addresses -- eg

dhcp-host=11:22:33:44:55:66,192.168.0.60


IMO dhcp is the shiznit -- it tends to "Just Work". dnsmasq is especially good, becuase it lets you effectively inherit DNS names...


on another note, have you tried

emerge unmerge dhcp

? I don't think you need it, despite your problems when you renamed it. I certainly do not have it and my Gentoo box is acting as a gateway fine.

Moo
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 4:03 pm    Post subject: Reply with quote

Thanks guys. The truth is it would be impossible for me to run Linux/gentoo without your help, so your input is very much appreciated.

Adding eth0 to the default run level seems to have done the trick. However DHCP continues to to run at boot time. Only in this instance it is no longer being used. I have done an emerge search for DHCP and have unmerged everything that related to dhcp. According to emerge I no longer have anything to dhcp installed. Yet dhcp continues to run at boot time.

The only drawback is that it slows down my boot times slightly.

Lol, well it might not be a bad thing. I mean if I can have a static IP and still have DHCP running, then at least if there is a scanario where I need to assign dhcp to a device connected directly to my PC, I should still be able to do it.

But I sure wish I understood after all I have done *why* it is still able to run. Not knowing is a bit too much live vodoo for me. I prefer to understand these things.

Anyhoo, at least I have what is a fairly distinct resolution.

As I said, thanks for your input. I have learned a lot and it's pretty much all down to you guys.

Best regards,

GJ
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 4:05 pm    Post subject: Reply with quote

PS

how do I check what my IP is from the CL? I know how to do it in Windows, but I just want to confirm with my own eyes that I am finally up and running.

GJ
Back to top
View user's profile Send private message
Yoda_Oz
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 143
Location: Southampton, UK

PostPosted: Sat Aug 07, 2004 4:46 pm    Post subject: Reply with quote

ifconfig ethx - where x is a number. ususally 0 or 1.
_________________
DELL INSPIRON 5150 (2004)
Intel P4 HT 3.06
512Mb
nVidia GeForce FX Go5200 64Mb
Actiontec 802CAT1 Wireless PCMCIA
Linux Kernel vmlinuz-2.6.10-2-386
Back to top
View user's profile Send private message
raid517
l33t
l33t


Joined: 06 Mar 2003
Posts: 946

PostPosted: Sat Aug 07, 2004 6:05 pm    Post subject: Reply with quote

Yeah that works thanks.

Code:
eth0      Link encap:Ethernet  HWaddr 00:50:8D:F6:4A:3B
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:126 errors:0 dropped:0 overruns:0 frame:0
          TX packets:166 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:113932 (111.2 Kb)  TX bytes:14089 (13.7 Kb)
          Interrupt:20


I am still curious how dhcp could work even though by all the laws of logic it shouldn't even be there any more. But oh well, this is still genuine progress.

GJ
Back to top
View user's profile Send private message
Yoda_Oz
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 143
Location: Southampton, UK

PostPosted: Sat Aug 07, 2004 7:00 pm    Post subject: Reply with quote

glad to help...

yeah that dchp thingie is kinda strange... oh well, at least it all works!
_________________
DELL INSPIRON 5150 (2004)
Intel P4 HT 3.06
512Mb
nVidia GeForce FX Go5200 64Mb
Actiontec 802CAT1 Wireless PCMCIA
Linux Kernel vmlinuz-2.6.10-2-386
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum