[SOLVED] Why is OpenWrt is not getting an IP address after configuration changes

I’m trying to install OpenWrt on an hp-PRODESK-600/8GB ram/240GB ssd with only one Ethernet port. The PRODESK has a monitor and keyboard and mouse and the second Ethernet port necessary for OpenWrt is a USB3<->Ethernet adapter model RT8152.
The steps I followed, after many different attempts, was brought down to the most basic procedure: On a Linux/Fedora39 PC, I downloaded the OpenWrt 23.05.2 version and unzip.

/releases / 23.05.2 / targets / x86 / 64 / generic-ext4-combined-efi.img.gz

Utilizing Fedora-Media-Writer, I “burned” the image onto the Kingston 240GB HDD.
Now the bootable SSD is inserted into the PRODESK mini-PC.
OpenWrt, by default, is supplying an Ethernet address to the Fedora PC, reconnected straight to the PRODESK port. The Fedora PC can now access LuCI via the web browser, as well as by SSH on a Terminal window.

This arrangement is not connected to the Internet yet.

It is now possible to proceed with some temporary changes to OpenWrt so that it can connect to the Internet and “opkg update” and install some other drivers like for the RT8152.
Following some instructions I got from YouTube, it is instructed to modify the “/etc/config/dhcp” file and “/etc/config/network” file, so that OpenWrt can connect the Internet. YouTube link, for those who are interested

Here are the modifications:
In dhcp/lan, add the line option ignore ‘1’ so that OpenWrt do not issue an address from the Ethernet port, but would turn the computer to receive a DHCP address from a DHCP server (the Home Router)
In network/lan,
option ipaddr ‘192.168.1.1’ change to 172.172.1.120
add option dns ‘172.172.1.1’
add option gateway ‘172.172.1.1’
( these addresses in accordance with the Router DHCP parameters )

These changes are valid and have been thoroughly tested with another Raspberry Pi4 installation and been determined to work completely fine. Once the changes are instantiated with a “reboot” OpenWrt will boot properly and a multitude of lines are shown on the PRODESK monitor.

It is here that the problem occur. The Ethernet connection to the Router does not take place anymore. Now the PRODESK Ethernet port is supposed to receive an IP address issued by the Router.

At this point it is possible to access the Router with the Fedora PC and look at the list of DHCP issued connected devices. The only connected device present in the Router is the Fedora PC. The PRODESK OpenWrt PC is not issued an IP address.
Prior to this installation, the same procedure was performed on a Raspberry Pi4 and all went well. Now that I am repeating them on the PRODESK PC, no IP address is issued to OpenWrt, hence I cannot access LuCI.

What am I missing ?

Since your use case is ultimately a lan->wan router, go ahead and create the wan network, with the one Ethernet port you have in it.

Add:

config interface 'wan'
    option proto 'dhcp'
    option device 'eth0'

Remove eth0 from br-lan. A physical port can only be attached to one thing at a time.

When you restart the network this should have OpenWrt connected to the Internet. But you will only have the local keyboard and screen for control unless you modify the firewall to allow ssh and/or http through wan.

Using opkg on the Internet connection, install the 8152 driver. Once you have two Ethernet ports working you can reassign them.

Are you sure that this is the correct upstream subnet? This is not a proper RFC1918 address, and therefore is in the publicly routable range.

Not if you have a static IP address assigned.

If you you want it to get an address via DHCP, change the lan proto to dhcp and remove the other fields (subnet mask, IP address, and dns).

Can you show us the output of

cat /etc/config/network

(if you are unable to reach this over a network, a photo is fine, but please make sure it is clear).

Here are the two original config files.
dhcp and network
not modified
original as found on first boot.

Coming soon
the modified versions

DHCP


config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'
        option filter_aaaa '0'
        option filter_a '0'

config dhcp 'lan'                                              
        option interface 'lan'                                 
        option start '100'                                     
        option limit '150'                                     
        option leasetime '12h'                                 
        option dhcpv4 'server'                                 
        option dhcpv6 'server'                                 
        option ra 'server'          
        option ra_slaac '1'         
        list ra_flags 'managed-config'
        list ra_flags 'other-config'  
                                      
config dhcp 'wan'                     
        option interface 'wan'        
        option ignore '1'             
                                      
config odhcpd 'odhcpd'                
        option maindhcp '0'           
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

NETWORK

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd18:324a:da53::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

You've provided the DHCP file twice, and not the network file.

Am I to assume that these mods are to occur in the "network" config file ?
and
"Remove eth0 from br-lan" what section of network should that take place ?
thanks

Previous message NETWORK corrected
Modified version coming

There are two easy options (select only one; option 2 may be more practical for now):

  1. set the lan interface to dhcp like this:
config interface 'lan'
        option device 'br-lan'
        option proto 'dhcp'

or

  1. add a wan interface (with DHCP) after removing eth0 from br-lan. Like this:
    Edit br-lan to remove eth0:
config device
        option name 'br-lan'
        option type 'bridge'

then add the wan interface

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'
1 Like

Just to inform that these addresses are not really a concern since they are occurring strictly between the OpenWrt and the dedicated NETGEAR router. Not exposed to any other computers nor WAN. I probably can put any address, I think ?

Understood. But It is usually best practice to only use RFC1918 addresses even when there is no wan -- this makes it less likely to have issues should you migrate the systems to an online state. Besides, it reduces potential confusion as we review your configs. But as long as there is no internet connectivity, it won't directly cause any issues.

1 Like

Here would be the modified version according to your instructions:
Please confirm:

DHCP

config dnsmasq                             
        option domainneeded '1'                                
        option boguspriv '1'                                   
        option filterwin2k '0'                                 
        option localise_queries '1'        
        option rebind_protection '1'                           
        option rebind_localhost '1'                            
        option local '/lan/'                                   
        option domain 'lan'                
        option expandhosts '1'                                 
        option nonegcache '0'                                  
        option cachesize '1000'                                
        option authoritative '1'           
        option readethers '1'                                  
        option leasefile '/tmp/dhcp.leases'                    
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'      
        option localservice '1'     
        option ednspacket_max '1232'  
        option filter_aaaa '0'        
        option filter_a '0'           
                                    
config device                         
        option name 'br-lan'          
        option type 'bridge'          
                                      
config interface 'wan'                
        option device 'eth0'                
        option proto 'dhcp'    
        
config dhcp 'lan'                                              
        option interface 'lan'                                 
        option start '100'                                     
        option limit '150'                 
        option leasetime '12h'                                 
        option dhcpv4 'server'                                 
        option dhcpv6 'server'                                 
        option ra 'server'          
        option ra_slaac '1'         
        list ra_flags 'managed-config'
        list ra_flags 'other-config'  
                                      
config dhcp 'wan'                   
        option interface 'wan'        
        option ignore '1'             
                                      
config odhcpd 'odhcpd'                
        option maindhcp '0'           
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

No, the changes were supposed to happen in the network file.

1 Like

OK. Sorry for the newbie question. Just to make sure.

Should I read instead:
after removing eth0 from the "config device" section of the "network" file

I said that you need to remove eth0 from br-lan. The definition for br-lan is a config device stanza, so sure, you can read it as you re-wrote. However, it is important to be precise insofar as there could be multiple devices defined (in your file, br-lan is the only one, but other products may have multiple devices, depending on the context and configuration).

Ultimately, you are taking the stanza below and simply removing the last line.

1 Like

I reset the SSD to original OpenWrt image.
Did mods from your proposed option 2
Reboot
The PC still not getting an IP address from the router.
ethernet wires are tested OK.
Both PRODESK and Fedora are on the same router.
Fedora is getting an IP but not PRODESK.
Fedora has access to the internet from the router.
PRODESK , no internet.

Try this:

  • unpug the ethernet cable from the prodesk device.
  • use that same cable and connect it to your regular computer (linux, mac, windows), with the ethernet adapter set to obtain an address via DHCP.

What happens?

that is from the PRODESK Ethernet wire re-connected
NETGEAR router to Fedora
FedoraConnectToNETGEAR

And that is set to get its address via DHCP?

Plug the ethernet cable back into the prodesk box and then show the ouput of:

logread -e udhcpc

For some odd reason, I now have connection from the router.
Was able to opkg update.
thanks, I'm back on track to continue my configuration.
I decided, for the nth time, to re-flash the SSD and redo your proposed mods.
Must have done that 5 or 6 times now.
I which I knew what changed.

Is it possible that some of those mods are not taking effect immediately on the following boot?
There's gotta be some explanation.

Now the PRODESK got IP 172.172.1.103
If I plug that address in Fedora browser I should see LuCI
But I get a message ERR_CONNECTION_REFUSED
ping from Fedora is showing a response.
Could there be a firewall rule preventing OpenWrt to respond ?

Yes by default incoming connections from the wan are blocked.

A rule like this can be added:

config rule
    option name 'Allow-Luci-https-WAN'
    option dest 'wan'
    option dest_port '443'
    option proto 'tcp'
    option target ACCEPT

Note you will need to explicitly specify https://routerip in your browser, since port 80 is still blocked the automatic redirection to https will not work. And of course remove this rule when connecting the OpenWrt box directly to the Internet.

1 Like