# Static IP works fine - DHCP doesn't get an IP address-Solved

## fastback69

I have one NIC in my system and /etc/conf.d/net works fine static with these settings:

```
config_eth0="10.1.1.8 netmask 255.255.255.0"

routes_eth0="default via 10.1.1.1"

dns_servers_eth0="10.1.1.1"
```

In the past to use a dhcp configuration and grab an IP from my router I would have this line active in my /etc/conf.d/net file

```
config_eth0="dhcp"
```

If I setup my system for dhcp my eth0 interface looks like this:

```
eth0      Link encap:Ethernet  HWaddr 00:0e:0c:00:15:43  

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:82349 errors:0 dropped:0 overruns:0 frame:0

          TX packets:64006 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:66905720 (63.8 MiB)  TX bytes:17707651 (16.8 MiB)

          Memory:e2120000-e2140000
```

Any ideas on what I'm missing?

I don't mind static by my router is lame and requires a dhcp lease before I can forward ports to an IP...  :Rolling Eyes: Last edited by fastback69 on Sat Jun 12, 2010 4:55 am; edited 1 time in total

----------

## Hu

 *fastback69 wrote:*   

> Any ideas on what I'm missing?

 I assume you checked the obvious, such as that you have a DHCP client installed and that the initscripts invoke it correctly.  As best I can tell, you have done everything correctly for the DHCP case.  What DHCP client are you using?  What is the output of emerge --pretend --verbose on that client?  Are you using baselayout 1 or 2?  The output of emerge --info will answer this question, and may be useful in other ways.

Does your DHCP client print any messages to the system logs as it runs?  Do you eventually acquire an IPv4LL address or does the interface stay in the configuration you showed in the ifconfig output?  Can you perform a packet capture to confirm that the client sends out a request and receives no response?  Do you have any non-Gentoo machines that can successfully acquire an address via DHCP?  Although rare, I have heard of DHCP servers that were so broken they only responded to one particular DHCP client, usually the Windows one.

----------

## chithanh

Does dhcpcd acquire an IP address if you launch it manually?

----------

## dylix

the wireless card in my htpc does that.. it wont get an ip addy from dhcp, in linux or windows lol.. 

odd indeed, but i've just learned to live with it i guess  :Laughing: 

----------

## fastback69

I do have a dhcp client installed and it does run when booting the system.

[ebuild   R   ] net-misc/dhcpcd-5.2.2 

If I manually run or restart  /etc/init.d/dhcpcd when trying to acquire a dhcp address it will fail to get an IP.

If I manually run or restart /etc/init.d/dhcpcd when set with static data in /etc/conf.d/net the static settings work fine and the NIC is configured properly.

emerge -pv dhcpcd shows:

```
emerge --pretend --verbose dhcpcd

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] net-misc/dhcpcd-5.2.2  USE="zeroconf" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB
```

emerge --info shows:

```
Portage 2.1.8.3 (default/linux/amd64/10.0/desktop, gcc-4.4.3, glibc-2.11.1-r0, 2.6.31-gentoo-r4 x86_64)

=================================================================

System uname: Linux-2.6.31-gentoo-r4-x86_64-Intel-R-_Core-TM-2_Extreme_CPU_Q6850_@_3.00GHz-with-gentoo-2.0.1

Timestamp of tree: Fri, 04 Jun 2010 03:30:01 +0000

app-shells/bash:     4.1_p7

dev-java/java-config: 2.1.11

dev-lang/python:     2.6.5-r2, 3.1.2-r3

dev-util/cmake:      2.8.1-r2

sys-apps/baselayout: 2.0.1

sys-apps/openrc:     0.6.1-r1

sys-apps/sandbox:    2.2

sys-devel/autoconf:  2.13, 2.65

sys-devel/automake:  1.8.5-r3, 1.9.6-r2, 1.10.3, 1.11.1

sys-devel/binutils:  2.20.1-r1

sys-devel/gcc:       4.4.3-r2

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.7b

virtual/os-headers:  2.6.33

ACCEPT_KEYWORDS="amd64 ~amd64"

ACCEPT_LICENSE="* -@EULA dlj-1.1"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=core2 -mcx16 -msahf -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config /var/lib/hsqldb"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=core2 -mcx16 -msahf -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"

GENTOO_MIRRORS="http://distfiles.gentoo.org"

LDFLAGS="-Wl,-O1"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X a52 aac acl acpi alsa amd64 asf avi berkdb bluetooth branding bzip2 cairo cdr cli consolekit cracklib crypt cups cxx dbus divx4linux dri dts dvd dvdr dvdread emboss encode exif fam fame firefox flac fortran gdbm gif gnutils gpm hal iconv ipv6 java jpeg kde lcms ldap libnotify mad matroska mikmod mmx mng modules mp3 mp4 mpeg mudflap multilib mysql ncurses nls nptl nptlonly nsplugin ogg opengl openmp oss pam pango pcre pdf perl png ppds pppd python qt qt3support qt4 quicktime readline reflection samba scanner sdl server session spell spl sql sse sse2 ssl startup-notification subtitles svg symlink sysfs tcpd tiff truetype unicode usb vorbis webkit wma wxwindows x264 xcb xine xinerama xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="vesa nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
```

If there's no obvious fix I may swap NIC's or upgrade my kernel and rebuild the module and dhcpcd.

I've seen this before on wireless networks, but never a wired connection.

----------

## fastback69

 *chithanh wrote:*   

> Does dhcpcd acquire an IP address if you launch it manually?

 

To be clear on this question - currently no it does not.

----------

## d2_racing

Can you post this after a fresh boot :

```

# rc-update show

# rc-status

```

----------

## cach0rr0

 *fastback69 wrote:*   

> To be clear on this question - currently no it does not.

 

what's the exact error if you run it from a command line? just a timeout?

```

#dhcpcd eth0

```

I also find it odd your router wants a *dynamic* address before it will forward ports - this seems very, very, very backwards. Like, so backwards it's just flat wrong behaviour. 

One other point to touch on from above, when you've assigned a static IP, restarting dhcpcd init is pointless; you are using static, dhcpcd init script fires off dhcpcd.

----------

## fastback69

OK, here's the stuff requested.

After a clean reboot with dhcp enabled -

rc-update show

```
             bootmisc | boot                                          

              hwclock | boot                                          

                 dbus |                     default                   

              modules | boot                                          

                 fsck | boot                                          

         termencoding | boot                                          

               net.lo | boot                                          

                devfs |             sysinit                           

             mount-ro |                                       shutdown

            savecache |                                       shutdown                                               

                samba |                     default                                                                  

               sysctl | boot                                                                                         

                 hald |                     default                                                                  

       udev-postmount |                     default                                                                  

           localmount | boot                                                                                         

                cupsd |                     default                                                                  

            alsasound | boot                                                                                         

             netmount |                     default                                                                  

            killprocs |                                       shutdown                                               

            syslog-ng |                     default                                                                  

                 swap | boot                                                                                         

                 sshd |                     default                                                                  

           vixie-cron |                     default                                                                  

                local |                     default nonetwork         

             hostname | boot                                          

             net.eth0 |                     default                   

                 mtab | boot                                          

          consolefont | boot                                          

                 udev |             sysinit                           

                 root | boot                                          

               procfs | boot                                          

              urandom | boot                                          

                dmesg |             sysinit                           

              keymaps | boot
```

rc-status

```
Runlevel: default

 dbus                                                              [  started  ]

 net.eth0                                                          [  started  ]

 syslog-ng                                                         [  started  ]

 cupsd                                                             [  started  ]

 samba                                                             [  started  ]

 hald                                                              [  started  ]

 udev-postmount                                                    [  started  ]

 netmount                                                          [  started  ]

 sshd                                                              [  started  ]

 vixie-cron                                                        [  started  ]

 local                                                             [  started  ]

Dynamic Runlevel: hotplugged

 net.eth0                                                          [  started  ]

Dynamic Runlevel: needed

 sysfs                                                             [  started  ]

 consolekit                                                        [  started  ]

Dynamic Runlevel: manual
```

...and manually kicking off dhcpcd

```
localhost # dhcpcd eth0 start

dhcpcd: version 5.2.2 starting

dhcpcd: start: interface not found or invalid

dhcpcd: eth0: rebinding lease of 10.1.1.3

dhcpcd: eth0: NAK: from 10.1.1.1

dhcpcd: eth0: broadcasting for a lease

dhcpcd: eth0: offered 10.1.1.8 from 10.1.1.1

dhcpcd: eth0: acknowledged 10.1.1.8 from 10.1.1.1

dhcpcd: eth0: checking for 10.1.1.8

dhcpcd: eth0: leased 10.1.1.8 for 31536001 seconds

dhcpcd: eth0: MTU set to 1400

dhcpcd: forking to background

localhost # ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:1c:c0:4b:40:c9  

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:257 errors:0 dropped:0 overruns:0 frame:0

          TX packets:326 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:121644 (118.7 KiB)  TX bytes:49444 (48.2 KiB)

          Memory:e2100000-e2120000 
```

Everything looks good, but I don't get an IP bound to the NIC - 

My router is a WiMax Motorola unit. The firmware is terrible, and the port forwarding issue made no sense to me either.

After three weeks of trial & error this is how the router 'needs' to work to forward ports - Not ideal, but it works as long as my systems can grab a dhcp ip  :Wink: 

----------

## cwr

Ok, what happens if you kick eth0 with ifconfig, eg:

  ifconfig eth0 10.1.1.8 netmask 255.255.255.0

Can ifconfig in fact set an address on eth0?  If not, it looks

like some driver problem.

Will

----------

## d2_racing

Can you try the manual way with ifconfig and tell us more.

----------

## fastback69

I spent more time on this and finally found a work around to the issue.

I tried another NIC with a driver that I knew was built into the kernel - same issue.

I upgraded my system kernel and recompiled close to everything on the box... (emerge -e system) - Same issue.

I un-installed and re-installed net-misc/dhcpcd-5.2.2 - same issue - 

Then I thought maybe a new version of dhcp was installed that I didn't remember...

I started back-revving versions - 

When I masked >=net-misc/dhcpcd-5.0 I was able to pull down net-misc/dhcpcd-4.0.15

After this was installed, and I rebooted, dhcp worked as expected.

There must be some config files that need to be manually updated or something that I missed.

Very strange that of all the packages out there, this one that's been around forever chose me to break on....

Thanks for your help guys - sorry this is a hack work around vs a root cause solution.

----------

## d2_racing

Weird problem, but can you retry and upgrade to the latest dhcpcd package, maybe you will be ok now.

----------

