{"id":158,"date":"2024-06-20T19:38:02","date_gmt":"2024-06-20T17:38:02","guid":{"rendered":"https:\/\/blog.douwedevri.es\/?p=158"},"modified":"2025-02-19T00:49:44","modified_gmt":"2025-02-18T22:49:44","slug":"openwrt-on-raspberry-pi-4","status":"publish","type":"post","link":"https:\/\/blog.dbdv.nl\/?p=158","title":{"rendered":"OpenWrt on Raspberry Pi 4"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" class=\"wp-image-167\" style=\"width: 150px;\" src=\"https:\/\/blog.douwedevri.es\/wp-content\/uploads\/2024\/06\/COLOUR-Raspberry-Pi-Symbol-Registered-300x300-1.png\" alt=\"\" srcset=\"https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2024\/06\/COLOUR-Raspberry-Pi-Symbol-Registered-300x300-1.png 300w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2024\/06\/COLOUR-Raspberry-Pi-Symbol-Registered-300x300-1-150x150.png 150w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Installing OpenWrt on a Raspberry Pi 4 with ethernet dongle as WAN port and on board ethernet as LAN port.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before we start, make sure that you have all the required packages installed. Take a look at <a href=\"https:\/\/openwrt.org\/docs\/guide-developer\/toolchain\/install-buildsystem\">https:\/\/openwrt.org\/docs\/guide-developer\/toolchain\/install-buildsystem<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First download the git repository.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\"># Download and update the sources\ngit clone https:\/\/git.openwrt.org\/openwrt\/openwrt.git\ncd openwrt\ngit pull<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have the latest version of OpenWrt we select a version of choice.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\"># Select a specific code revision\ngit branch -a\ngit tag\ngit checkout v23.05.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we update and install the feeds. Also custom feeds can be added at this point.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\"># Update the feeds\n.\/scripts\/feeds update -a\n.\/scripts\/feeds install -a<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At this point we configure the image. After running the following command we need to change a few settings. Enable settings by pressing <kbd>space<\/kbd> until a <kbd>*<\/kbd> appears.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Target System should be <code>Broadcom BCM27xx<\/code>.<\/li>\n\n\n\n<li>Subtarget should be <code>BCM2711 boards (64 bit)<\/code>. (After selecting that you should see Raspberry Pi 4B in Target Profile.)<\/li>\n\n\n\n<li>In Target Images, only <code>squashfs<\/code> should be enabled and the Root filesystem must be enlarged to fit the SD card. For example 12000 MiB for a 16 GB SD card. This can be automatically expanded after installation.<\/li>\n\n\n\n<li>In Kernel modules, go to USB Support and select <code>kmod-usb-net-asix-ax88179<\/code> or <code>kmod-usb-net-rtl8150<\/code> depending on your ethernet adapter. And select <code>kmod-usb2<\/code> and <code>kmod-usb3<\/code>.<\/li>\n\n\n\n<li>In LuCI, go to Collections and enable <code>luci<\/code>, <code>luci-ssl<\/code>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">After that exit and save.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\"># Configure the firmware image\nmake menuconfig<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">One last step before we compile the system is to add some configuration files. This is the network file that indicates which IP range should be used, and which port should act as WAN and LAN. Do this by creating the following folders first.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">mkdir -p files\/etc\/config\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And then add the following contents to the file: <code>files\/etc\/config\/network<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"\" class=\" line-numbers\">config interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\toption ipaddr '127.0.0.1'\n\toption netmask '255.0.0.0'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd6e:bdeb:1e0c::\/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'eth0'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.8.1'\n\toption netmask '255.255.255.0'\n\toption ip6assign '60'\n\tlist dns '1.1.1.1'\n\nconfig interface 'WAN'\n\toption proto 'dhcp'\n\toption device 'eth1'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next the DHCP file which makes it easy to connect to the network by giving us an IP instead of needing to manually configure that. Add the following section to the file <code>files\/etc\/config\/dhcp<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">config dnsmasq\n\toption domainneeded '1'\n\toption boguspriv '1'\n\toption filterwin2k '0'\n\toption localise_queries '1'\n\toption rebind_protection '1'\n\toption rebind_localhost '1'\n\toption local '\/lan\/'\n\toption domain 'lan'\n\toption expandhosts '1'\n\toption nonegcache '0'\n\toption cachesize '1000'\n\toption authoritative '1'\n\toption readethers '1'\n\toption leasefile '\/tmp\/dhcp.leases'\n\toption resolvfile '\/tmp\/resolv.conf.d\/resolv.conf.auto'\n\toption nonwildcard '1'\n\toption localservice '1'\n\toption ednspacket_max '1232'\n\toption filter_aaaa '0'\n\toption filter_a '0'\n\nconfig dhcp 'lan'\n\toption interface 'lan'\n\toption leasetime '12h'\n\toption start '100'\n\toption limit '150'\n\toption dhcpv4 'server'\n\toption dhcpv6 'server'\n\toption ra 'server'\n\tlist ra_flags 'managed-config'\n\tlist ra_flags 'other-config'\n\nconfig dhcp 'wan'\n\toption interface 'wan'\n\toption ignore '1'\n\nconfig odhcpd 'odhcpd'\n\toption maindhcp '0'\n\toption leasefile '\/tmp\/hosts\/odhcpd'\n\toption leasetrigger '\/usr\/sbin\/odhcpd-update'\n\toption loglevel '4'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And the last configuration file to creates a wireless network for us to connect to. Add the following bit to the file <code>files\/etc\/config\/wireless<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">config wifi-device 'radio0'\n\toption type 'mac80211'\n\toption path 'platform\/soc\/fe300000.mmcnr\/mmc_host\/mmc1\/mmc1:0001\/mmc1:0001:1'\n\toption channel '36'\n\toption band '5g'\n\toption htmode 'VHT80'\n\toption cell_density '0'\n\nconfig wifi-iface 'default_radio0'\n\toption device 'radio0'\n\toption network 'lan'\n\toption mode 'ap'\n\toption ssid 'Douwe'\n\toption encryption 'psk2'\n\toption key '0penWrt!!'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we are done with the configuration files, is it time to build the image. We can do this in two steps. First we download all that is needed. and then we build.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">make download\n\n# Build the firmware image\nmake -j$(nproc)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Final stap is to put the image on a SD card. That can be done with balenaEtcher, or any program of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing OpenWrt on a Raspberry Pi 4 with ethernet dongle as WAN port and on board ethernet as LAN port. Before we start, make sure that you have all the required packages installed. Take a look at https:\/\/openwrt.org\/docs\/guide-developer\/toolchain\/install-buildsystem. First download the git repository. Now that we have the latest version of OpenWrt we select a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":165,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[21,20,19],"class_list":["post-158","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-network","tag-openwrt","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":9,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/224"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/media\/165"}],"wp:attachment":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}