Build Home Router with OpenWrt – Works as a Router
In the previous post, We run openwrt image on Raspberry Pi 3B, but that is only bring openwrt up, it is not a router.
Setup network
Now with this patch we set eth0 as wan and wlan0 as lan:
diff --git a/target/linux/brcm2708/base-files/etc/board.d/02_network b/target/linux/brcm2708/base-files/etc/board.d/02_network
index c8449bb..480b5d6 100755
--- a/target/linux/brcm2708/base-files/etc/board.d/02_network
+++ b/target/linux/brcm2708/base-files/etc/board.d/02_network
@@ -17,7 +17,8 @@ raspberrypi,model-b-rev2 |\
raspberrypi,2-model-b |\
raspberrypi,3-model-b |\
raspberrypi,3-model-b-plus)
- ucidef_set_interface_lan "eth0"
+ ucidef_set_interface_lan "wlan0"
+ ucidef_set_interface_wan "eth0" "dhcp"
;;
raspberrypi,model-zero-w)
After bootup, we can see interface eth0 was correctly configured and ip address was set to 192.168.123.15 by dhcp server:
root@OpenWrt:/# ifconfig
eth0 Link encap:Ethernet HWaddr B8:27:EB:C3:53:CC
inet addr:192.168.123.15 Bcast:192.168.123.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fec3:53cc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45 errors:0 dropped:0 overruns:0 frame:0
TX packets:71 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4001 (3.9 KiB) TX bytes:8156 (7.9 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1765 (1.7 KiB) TX bytes:1765 (1.7 KiB)
Network Configuration
Network configuration was saved in /etc/config/network
root@OpenWrt:/# cat /etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd64:ae09:ff96::/48'
config interface 'lan'
option type 'bridge'
option ifname 'wlan0'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option ifname 'eth0'
option proto 'dhcp'
config interface 'wan6'
option ifname 'eth0'
option proto 'dhcpv6'
Wireless Configuration
Because radio interface was disabled by default, so we cannot find ssid of our router:
root@OpenWrt:/# cat /etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option path 'platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
option htmode 'HT20'
option disabled '1'
config wifi-iface 'default_radio0'
option device 'radio0'
option network 'lan'
option mode 'ap'
option ssid 'OpenWrt'
option encryption 'none'
Enable wireless:
uci set wireless.radio0.disabled=0
/etc/init.d/network restart
In the next post, we will make wireless enabled by default.
Bootup message
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.14.90 (fdbai@fdbai-desktop) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r8985-ddc9fd5)) #0 SMP Sun Jan 6 07:33:11 2019
[ 0.000000] CPU: ARMv7 Processor [410fd034] revision 4 (ARMv7), cr=10c5383d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Raspberry Pi 3 Model B Rev 1.2
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] cma: Reserved 16 MiB at 0x3a400000
[ 0.000000] random: get_random_bytes called from start_kernel+0x84/0x35c with crng_init=0
[ 0.000000] percpu: Embedded 16 pages/cpu @b9c35000 s33932 r8192 d23412 u65536
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 240792
[ 0.000000] Kernel command line: 8250.nr_uarts=1 bcm2708_fb.fbwidth=640 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 kgdboc=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=squashfs,ext4 rootwait
[ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[ 0.000000] Memory: 937856K/970752K available (4651K kernel code, 148K rwdata, 1212K rodata, 1024K init, 351K bss, 16512K reserved, 16384K cma-reserved)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xbb800000 - 0xff800000 (1088 MB)
[ 0.000000] lowmem : 0x80000000 - 0xbb400000 ( 948 MB)
[ 0.000000] modules : 0x7f000000 - 0x80000000 ( 16 MB)
[ 0.000000] .text : 0x80008000 - 0x8058ac64 (5644 kB)
[ 0.000000] .init : 0x80700000 - 0x80800000 (1024 kB)
[ 0.000000] .data : 0x80800000 - 0x80825380 ( 149 kB)
[ 0.000000] .bss : 0x8082a150 - 0x80881dc8 ( 352 kB)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[ 0.000000] Hierarchical RCU implementation.
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] arch_timer: cp15 timer(s) running at 19.20MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
[ 0.000007] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
[ 0.000020] Switching to timer-based delay loop, resolution 52ns
[ 0.000219] Console: colour dummy device 80x30
[ 0.000679] console [tty1] enabled
[ 0.000714] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
[ 0.000749] pid_max: default: 32768 minimum: 301
[ 0.000882] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000910] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.001436] CPU: Testing write buffer coherency: ok
[ 0.001778] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.002092] Setting up static identity map for 0x100000 - 0x100060
[ 0.002205] Hierarchical SRCU implementation.
[ 0.002715] smp: Bringing up secondary CPUs ...
[ 0.003295] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 0.003909] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[ 0.004493] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[ 0.004571] smp: Brought up 1 node, 4 CPUs
[ 0.004635] SMP: Total of 4 processors activated (153.60 BogoMIPS).
[ 0.004654] CPU: All CPU(s) started in HYP mode.
[ 0.004669] CPU: Virtualization extensions available.
[ 0.013675] VFP support v0.3: implementor 41 architecture 3 part 40 variant 3 rev 4
[ 0.013887] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.013926] futex hash table entries: 1024 (order: 4, 65536 bytes)
[ 0.014566] pinctrl core: initialized pinctrl subsystem
[ 0.015229] NET: Registered protocol family 16
[ 0.017467] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[ 0.020826] cpuidle: using governor ladder
[ 0.020865] cpuidle: using governor menu
[ 0.021319] Serial: AMBA PL011 UART driver
[ 0.022713] bcm2835-mbox 3f00b880.mailbox: mailbox enabled
[ 0.023109] uart-pl011 3f201000.serial: could not find pctldev for node /soc/gpio@7e200000/uart0_pins, deferring probe
[ 0.047318] bcm2835-dma 3f007000.dma: DMA legacy API manager at bb813000, dmachans=0x1
[ 0.049017] SCSI subsystem initialized
[ 0.049210] usbcore: registered new interface driver usbfs
[ 0.049268] usbcore: registered new interface driver hub
[ 0.049333] usbcore: registered new device driver usb
[ 0.050030] raspberrypi-firmware soc:firmware: Attached to firmware from 2018-11-23 19:36
[ 0.051055] clocksource: Switched to clocksource arch_sys_counter
[ 0.055497] NET: Registered protocol family 2
[ 0.056045] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.056170] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[ 0.056369] TCP: Hash tables configured (established 8192 bind 8192)
[ 0.056500] UDP hash table entries: 512 (order: 2, 16384 bytes)
[ 0.056558] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
[ 0.056743] NET: Registered protocol family 1
[ 0.057861] Crashlog allocated RAM at address 0x3f00000
[ 0.058024] workingset: timestamp_bits=30 max_order=18 bucket_order=0
[ 0.061759] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.063186] io scheduler noop registered
[ 0.063207] io scheduler deadline registered
[ 0.063319] io scheduler cfq registered (default)
[ 0.065895] BCM2708FB: allocated DMA memory fa510000
[ 0.065939] BCM2708FB: allocated DMA channel 0 @ bb813000
[ 0.075565] Console: switching to colour frame buffer device 80x30
[ 0.084677] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[ 0.088447] vc-mem: phys_addr:0x00000000 mem_base=0x3ec00000 mem_size:0x40000000(1024 MiB)
[ 0.094647] vc-sm: Videocore shared memory driver
[ 0.104338] brd: module loaded
[ 0.110916] loop: module loaded
[ 0.114271] libphy: Fixed MDIO Bus: probed
[ 0.117253] usbcore: registered new interface driver lan78xx
[ 0.120207] usbcore: registered new interface driver smsc95xx
[ 0.123041] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 0.153693] dwc_otg 3f980000.usb: base=0xf0980000
[ 0.356561] Core Release: 2.80a
[ 0.359220] Setting default values for core params
[ 0.361920] Finished setting default values for core params
[ 0.564784] Using Buffer DMA mode
[ 0.567381] Periodic Transfer Interrupt Enhancement - disabled
[ 0.570053] Multiprocessor Interrupt Enhancement - disabled
[ 0.572721] OTG VER PARAM: 0, OTG VER FLAG: 0
[ 0.575323] Dedicated Tx FIFOs mode
[ 0.578167] WARN::dwc_otg_hcd_init:1046: FIQ DMA bounce buffers: virt = 0xba504000 dma = 0xfa504000 len=9024
[ 0.583640] FIQ FSM acceleration enabled for :
[ 0.583640] Non-periodic Split Transactions
[ 0.583640] Periodic Split Transactions
[ 0.583640] High-Speed Isochronous Endpoints
[ 0.583640] Interrupt/Control Split Transaction hack enabled
[ 0.597245] WARN::hcd_init_fiq:459: FIQ on core 1 at 0x80412cc8
[ 0.599881] WARN::hcd_init_fiq:460: FIQ ASM at 0x80412fe4 length 36
[ 0.602483] WARN::hcd_init_fiq:486: MPHI regs_base at 0xf0006000
[ 0.605106] dwc_otg 3f980000.usb: DWC OTG Controller
[ 0.607757] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[ 0.613068] dwc_otg 3f980000.usb: irq 62, io mem 0x00000000
[ 0.615919] Init: Port Power? op_state=1
[ 0.618684] Init: Power Port (0)
[ 0.621577] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 0.624428] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.630000] usb usb1: Product: DWC OTG Controller
[ 0.632853] usb usb1: Manufacturer: Linux 4.14.90 dwc_otg_hcd
[ 0.635698] usb usb1: SerialNumber: 3f980000.usb
[ 0.638876] hub 1-0:1.0: USB hub found
[ 0.641666] hub 1-0:1.0: 1 port detected
[ 0.644978] usbcore: registered new interface driver uas
[ 0.647744] usbcore: registered new interface driver usb-storage
[ 0.650400] mousedev: PS/2 mouse device common for all mice
[ 0.653009] i2c /dev entries driver
[ 0.656060] bcm2835-wdt 3f100000.watchdog: Broadcom BCM2835 watchdog timer
[ 0.659031] bcm2835-cpufreq: min=600000 max=1200000
[ 0.662126] sdhci: Secure Digital Host Controller Interface driver
[ 0.664913] sdhci: Copyright(c) Pierre Ossman
[ 0.667957] mmc-bcm2835 3f300000.mmc: could not get clk, deferring probe
[ 0.671134] sdhost-bcm2835 3f202000.mmc: could not get clk, deferring probe
[ 0.674141] sdhci-pltfm: SDHCI platform and OF driver helper
[ 0.680282] vchiq: vchiq_init_state: slot_zero = ba580000, is_master = 0
[ 0.682911] [vc_sm_connected_init]: start
[ 0.692804] [vc_sm_connected_init]: end - returning 0
[ 0.696518] NET: Registered protocol family 10
[ 0.700172] Segment Routing with IPv6
[ 0.703081] NET: Registered protocol family 17
[ 0.705883] 8021q: 802.1Q VLAN Support v1.8
[ 0.708974] Registering SWP/SWPB emulation handler
[ 0.716507] uart-pl011 3f201000.serial: cts_event_workaround enabled
[ 0.719352] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 0.726171] console [ttyS0] disabled
[ 0.729019] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 166, base_baud = 31250000) is a 16550
[ 0.861150] Indeed it is in host mode hprt0 = 00021501
[ 0.872331] console [ttyS0] enabled
[ 0.873073] mmc-bcm2835 3f300000.mmc: mmc_debug:0 mmc_debug2:0
[ 1.131077] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 1.136151] mmc-bcm2835 3f300000.mmc: DMA channel allocated
[ 1.155105] Indeed it is in host mode hprt0 = 00001101
[ 1.182475] random: fast init done
[ 1.644729] sdhost: log_buf @ ba507000 (fa507000)
[ 1.671281] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[ 1.681257] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 1.690296] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[ 1.700530] hub 1-1:1.0: USB hub found
[ 1.701943] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[ 1.716130] hub 1-1:1.0: 5 ports detected
[ 1.717661] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[ 1.731968] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ 1.741624] of_cfs_init
[ 1.747118] of_cfs_init: OK
[ 1.773738] Waiting for root device /dev/mmcblk0p2...
[ 1.775877] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[ 1.868714] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.885716] mmc0: new high speed SD card at address cb7d
[ 1.894532] mmcblk0: mmc0:cb7d SD01G 947 MiB
[ 1.902983] mmcblk0: p1 p2
[ 1.923394] mmc1: new high speed SDIO card at address 0001
[ 1.935949] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: (null)
[ 1.949593] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[ 1.961320] Freeing unused kernel memory: 1024K
[ 2.030044] init: Console is alive
[ 2.036706] init: - watchdog -
[ 2.061101] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 2.071133] Under-voltage detected! (0x00050005)
[ 2.164158] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[ 2.176791] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 2.191312] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ 2.201461] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 2.201712] init: - preinit -
[ 2.217549] smsc95xx v1.0.6
[ 2.314357] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:c3:53:cc
[ 2.314723] random: procd: uninitialized urandom read (4 bytes read)
[ 2.402744] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 2.413724] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 2.431115] usb 1-1.5: new full-speed USB device number 4 using dwc_otg
[ 2.587346] usb 1-1.5: New USB device found, idVendor=0a5c, idProduct=21ec
[ 2.597812] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2.611810] usb 1-1.5: Product: BCM20702A0
[ 2.619214] usb 1-1.5: Manufacturer: Broadcom Corp
[ 2.627326] usb 1-1.5: SerialNumber: 00198600164E
[ 5.230363] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 5.240874] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 6.494090] mount_root: mounting /dev/root
[ 6.502016] EXT4-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
[ 6.523421] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 6.563578] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 6.581927] urandom-seed: Seeding with /etc/urandom.seed
[ 6.611730] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 6.626360] procd: - early -
[ 6.632918] procd: - watchdog -
[ 7.252659] procd: - watchdog -
[ 7.259227] procd: - ubus -
[ 7.271891] random: ubusd: uninitialized urandom read (4 bytes read)
[ 7.316009] random: ubusd: uninitialized urandom read (4 bytes read)
[ 7.325660] random: ubusd: uninitialized urandom read (4 bytes read)
[ 7.335570] procd: - init -
Please press Enter to activate this console.
[ 7.446081] kmodloader: loading kernel modules from /etc/modules.d/*
[ 7.471937] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 7.487317] hidraw: raw HID events driver (C) Jiri Kosina
[ 7.499428] bcm2835_alsa bcm2835_alsa: card created with 8 channels
[ 7.521299] Loading modules backported from Linux version v4.19.7-0-g61c68f2a2af0
[ 7.534743] Backport generated by backports.git v4.19.7-1-0-g148b072d
[ 7.545969] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 7.559077] nf_conntrack version 0.5.0 (15360 buckets, 61440 max)
[ 7.585153] usbcore: registered new interface driver usbhid
[ 7.593811] usbhid: USB HID core driver
[ 7.606436] xt_time: kernel timezone is -0000
[ 7.626864] PPP generic driver version 2.4.2
[ 7.634876] NET: Registered protocol family 24
[ 7.651231] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[ 7.684160] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.txt failed with error -2
[ 7.702000] brcmfmac mmc1:0001:1: Falling back to user helper
[ 7.721453] firmware brcm!brcmfmac43430-sdio.raspberrypi,3-model-b.txt: firmware_loading_store: map pages failed
[ 7.863870] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[ 7.879782] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.clm_blob failed with error -2
[ 7.897320] brcmfmac mmc1:0001:1: Falling back to user helper
[ 7.916459] firmware brcm!brcmfmac43430-sdio.clm_blob: firmware_loading_store: map pages failed
[ 7.932818] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-11), device may have limited channels available
[ 7.955325] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 23 2017 03:55:53 version 7.45.98.38 (r674442 CY) FWID 01-e58d219f
[ 8.020788] usbcore: registered new interface driver brcmfmac
[ 8.032709] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 10.132887] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 11.691266] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 20.791115] Voltage normalised (0x00000000)
BusyBox v1.30.0 () built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt SNAPSHOT, r8987-5e584c9
-----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#