# Can't get dhcp to work at boot time



## geeko (Dec 5, 2018)

Hi everyone, 

I recently installed Freebsd 12 RC3, everything went extremely well. But after 1st boot I can't get any ip from dhcp. Search the forum for an user with similar issues but no matter the change to rc.conf I can't get an ip. 
Tried using SYNCDHCP and also adding timeout to dhclient.conf but nothing seems to work.

Boot shows Too many discovery requests, and other attempts but same result or 0.0.0.0 or no ip at all

Even more wierd, after logon if I call 

```
ifconfig re0 down
dhclient re0
```
It gets an ip in less than 5 seconds

I installed using memstick imagem

Hope someone can point me in the correct direction. 

Best regards


----------



## ShelLuser (Dec 5, 2018)

So what exactly did you set up in /etc/rc.conf? Just sharing that things don't work isn't very useful.


----------



## geeko (Dec 5, 2018)

Hi ShelLuser,

For sure, thanks for replying

`cat /etc/rc.conf`

```
hostname="mybox"

keymap="pt.acc.kbd"

ifconfig_re0="SYNCDHCP"

sshd_enable="YES"
ntpdate_enable="YES"

# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
```

PS> I dont know if it helps but this box has 2 network devices, re0 and re1

Best regards,


----------



## SirDice (Dec 6, 2018)

What's supplying the DHCP service? I had a dodgy cable modem a few years ago. And every time I rebooted my machine DHCP would fail on it. I had to turn the cable modem off and on again, then reboot my machine and DHCP would work again. Your issue could be caused by something similar.


----------



## geeko (Dec 6, 2018)

Hi SirDice,

The router serving DHCP is a residential gpon router from huawei. Other devices work ok (never noticed any issue even with new devices)

I suspected of a hw issue, but after booting this box with a live linux distro it gets a valid ip

... after reboot I can get an IP, but I have to login to restore network :-S ( I was planning to use this box as a gateway )

Best regards,


----------



## yuripv (Dec 6, 2018)

Can you provide the full boot log, showing what exactly is happening when it's trying to get an address?


----------



## geeko (Dec 6, 2018)

Hi yuripv,

ifconfig (after reboot, sometimes it gets like this)

```
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 74:d4:35:e0:5d:dc
    inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
re1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 74:d4:35:e0:b1:69
    media: Ethernet autoselect (100baseTX <full-duplex>)
    status: active
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
    inet 127.0.0.1 netmask 0xff000000 
    groups: lo 
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
```
or like this

```
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 74:d4:35:e0:5d:dc
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
re1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 74:d4:35:e0:b1:69
    media: Ethernet autoselect (100baseTX <full-duplex>)
    status: active
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
    inet 127.0.0.1 netmask 0xff000000 
    groups: lo 
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
```

netstat -rn (after reboot)

```
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
127.0.0.1          link#3             UH          lo0

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#3                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%lo0/64                     link#3                        U           lo0
fe80::1%lo0                       link#3                        UHS         lo0
ff02::/16                         ::1                           UGRS        lo0
```

I attached 2 photos, one from boot process (sometimes the boot process shows even more lines during dhclient) and the other after manually calling dhclient. 

Please, let me know if I can provide more info.

Thank you so much for all your time.

Best regards,


----------



## yuripv (Dec 7, 2018)

It looks like you are not alone with this problem, and if you can't replace the NICs with say something Intel, there are different workarounds suggested, e.g. https://forums.freebsd.org/threads/realtek-rtl8111-8168b-initialisation-problem.44806/post-267606.


----------



## geeko (Dec 7, 2018)

Lucky me.... :-(


```
re0@pci0:1:0:0:    class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x06 hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
```

thank you for your help sorting this out

Best regards


----------

