Cannot get DHCP lease from ISP

Hy guys, I have problem automatically getting DHCP lease from my ISP

Installed LEDE Reboot 17.01.7 on Linksys wrt3200acm and problem is:
If I set Wan protocol to DHCP client, I wont have internet until I call 'udhcpc -i eth1' from ssh
If I set Wan protocol to static IP and insert IP given by manually calling udhcpc then everything works fine.

I just would like to DHCP client to work out of the box. Can you please help me configuring it?

/etc/config/network https://pastebin.com/mU2KTtdN
/etc/config/dhcp https://pastebin.com/01BW05xL

1 Like

Version 17.01 is obsolete. 18.06.4 is recommended for most users.

Do not set gateway or dns in the LAN section. If you don't want your ISP's DNS, set a different one under wan. That setting will be inherited back to be advertised to DHCP clients on the LAN.

Other than whatever you're trying to do with DNS, default settings should suit your usage, try that first.

2 Likes

Try to upgrade to OpenWrt 18.06.4 and reset the settings to factory defaults.

thanks for prompt response.
Upgraded to OpenWrt 18.06.4 and removed unnecessary lan changes, but problem persists. This time I cannot get internet working even with 'udhcpc -i eth1.2'. Only works when I manually set up static ip, gateway and dns.
cat /etc/config/network https://pastebin.com/tzZCD6AM
cat /etc/config/dhcp https://pastebin.com/JNtmNxNL

2 Likes

Remove this and test.

Also show:

uci show network; uci show firewall
2 Likes

@vgaetera 'option clientid 'openwrt'' chrome tried to autofill that field. disabled chrome autofilling removed that field and was almost sure that it was my problem. but no..

So, sending you my 'uci show network; uci show firewall'
this config works for me:
https://pastebin.com/V2vPbye3
thsi doesnt:
https://pastebin.com/LEvVUTtc

1 Like
swconfig list; swconfig dev switch0 help; swconfig dev switch0 show
ip a; ip r; ip ru; iptables-save
1 Like

working config https://pastebin.com/GyDkhBcJ
broken config https://pastebin.com/63E03ch4

after running these commands internet still doesnt work (at this point I my unix knowledge is not enough to understand what those meant to do:) ).

1 Like

Set WAN mode to DHCP and test this:

opkg update
opkg install tcpdump
reset; \
. /lib/functions/network.sh; \
network_flush_cache; \
network_find_wan NET_IF; \
network_get_device NET_DEV "${NET_IF}"; \
ifup "${NET_IF}"; sleep 5; \
tcpdump -vni "${NET_DEV}" udp port 67 & \
ip address show dev "${NET_DEV}"; \
killall -SIGUSR2 udhcpc; sleep 5; \
ip address show dev "${NET_DEV}"; \
killall -SIGUSR1 udhcpc; sleep 5; \
ip address show dev "${NET_DEV}"; \
killall tcpdump

Checking the switch settings and verifying that runtime configuration matches persistent.

1 Like

okay I guess we found root cause of the problem. If I run these commands one by one:

root@OpenWrt:~#
root@OpenWrt:~# source /lib/functions/network.sh;
root@OpenWrt:~# network_flush_cache;
root@OpenWrt:~# network_find_wan NET_IF;
root@OpenWrt:~# network_get_device NET_DEV "${NET_IF}";
root@OpenWrt:~# ifup "${NET_IF}"; sleep 10;
Interface  not found
root@OpenWrt:~#

full output : https://pastebin.com/dQhdKjYG

same works fine with static config: https://pastebin.com/Mi8Lv08b

1 Like

Your switch config is strange because of 2 tagged CPU ports 5 and 6 while shconfig ... help shows CPU only on port 5, but I'm not experienced enough in configuring switches to declare it incorrect.
You can create a separate topic about it and ask someone to explain or verify if this is okay or not.

This is certainly not good because system services depend on this API.
We should consider how to troubleshoot it.

1 Like

I'm very thankful for your help!

But, now, I dont really understand problem you explained above :slight_smile: I would create separate post, but I dont really know how to describe problem and troubleshoot absence of ${NET_IF} . I can perform ssh commands if you have good ideas

It looks like we can't rely on the system bus until WAN interface obtains DHCP lease or has a static address and default gateway, so we need to troubleshoot with another method:

reset; \
NET_IF="wan"; \
NET_DEV="$(uci get network.${NET_IF}.ifname)"; \
ifup "${NET_IF}"; sleep 5; \
tcpdump -vni "${NET_DEV}" udp port 67 & \
ip address show dev "${NET_DEV}"; \
killall -SIGUSR2 udhcpc; sleep 5; \
ip address show dev "${NET_DEV}"; \
killall -SIGUSR1 udhcpc; sleep 5; \
ip address show dev "${NET_DEV}"; \
killall tcpdump
1 Like

working: https://pastebin.com/jiDtLC8D
broken: https://pastebin.com/1U8t8Ce6

1 Like

It sends multiple DHCPDISCOVER packets but recieves no DHCPOFFER.
Your DHCPDISCOVER looks fine, so we can assume that the DHCP client works properly.

There's a somewhat similar issue for IPv6:
IPv6 works only with wan in promiscuous mode

Although it shouldn't influence IPv4, we can still test this:

udhcpc -i $(uci get network.wan.ifname)
ip link set $(uci get network.wan.ifname) promisc on
udhcpc -i $(uci get network.wan.ifname)
1 Like

Could you show an example on how to do that?

On my setup, with 2 ISPs being load balanced by mwan3, I leave WANs alone and set DNS on VLAN DHCP. I had to set it directly on /etc/config/dhcp because couldn't get it working from Luci. If you need the code, I'll get it later when I'm home.