Help creating portable wifi bridge using br-lan on raspberry pi 4 CLI to usb_WIFI

I do not want to use the GUI. Old Sparc Unix user so comfortable with vi and shell programming and editing config files

I have two wifi interfaces on Raspberry Pi 4

  1. br-lan - which I want to connect to my home wifi
    I am looking to connect via CLI so simply need to connect to my home wifi or free wifi
    I can then use the opkg commands to update and install packages I need

  2. wan0 - will use usb_wifi as an acess point. Its a USB device and found drivers for it.
    It will give ip numbers for users who have the 'password' to HOMEWIFI

  3. Bridge which will allow me to connect wifi access point to br-lan using openvpn

I am basically trying to setup my own portable acess point so need to first connect the built in wifi
to my local lan. I want to use br-lan in 'STA' mode to first connect to my wifi to update packages and install drivers

files: /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'     
        option path 'platform/soc/fe300000.mmcnr/
        option channel '7'          # 36 to 7 
        option band '11g'           # changed to 11g
        option htmode 'VHT80'       # changed from VHT80 to HT20
        option disabled '0'         # turn it on!
        option short_gi_40 '0'
        option country 'US'
        option channel 'auto'
        option cell_density '0'. # not sure if its needed

config wifi-iface 'radio0'
        option device 'radio0'
        option network 'lan'
        option encryption 'psk2'
        option key 'StrongPassword'
        option ssid 'HOMEWIFI'   
        option mode 'sta'                 # connection to my wifi

file : /etc/config/network

config interface 'lan' 
        option device 'br-lan'
        option proto 'static'
        option ipaddr ''       
        option netmask  ''
        option ip6assign '60'
        option force_link '1' # to keep ip always

config interface 'wwan' 
        option proto 'dhcp' # public wifi iface
        option peerdns '0'
        option dns '' # google and cloudflare

config interface 'vpnclient'
        option ifname 'tun0'
        option proto 'none'

file: /etc/config/firewall

## change config zone wan one option
config zone
        option name      wan
        list network     'wan'
        list network     'wan6'
        option input     ACCEPT    # ACCEPT from REJECT
        option output    ACCEPT
        option forward   REJECT
        option masq      1
        option mtu_fix   1

file: /etc/config/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 authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.d/'
    option nonwildcard '1'
    option localservice '1'
    option ednspacket_max '1232'

config dhcp 'lan'
    option interface 'lan'
    option leasetime '12h'
    option dhcpv4 'server'
    option dhcpv6 'server'
    option ra 'server'
    list ra_flags 'managed-config'
    list ra_flags 'other-config'
        option ignore '1'  # 

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'

Sorry, misread you. You do have an extra USB WIFI, so it would work.

Hey, why not just use the web GUI, to create the wifi client. This will create the wifi config file for you and you can continue on the command line.
Its easier and faster. Why would anyone here on the forum need to take that over, if the web GUI can just create the required wifi client config on a few mouse clicks?

1 Like

I need to initially. bring up the wifi by ssh, so what files do I need to connect to a wifi network with a password?

If you already have an SSH connection, why not use http access to access the GUI once, to get proper init Wifi config files to start with?

The following are just sample WiFi configs from another device, that need adaptation to your environment. The GUI would just create/update the needed files, with adapted parameters to your device/environment.
You could then simply continue on those files via command line. The GUI operates on those config files and has no separate config storage, but does identify some of your device parts, which can be of help to init config, especially if you have custom USB-connected Wifi dongles.

If you hate the GUI to be present permanently, simply export the configs after short GUI usage, then reset the device/uninstall the GUI and you are back to start, but still have proper adapted Wifi config files for your device?


config interface 'wwan'
	option proto 'dhcp'


config wifi-device 'radio0'
	option type 'mac80211'
	option path 'platform/soc/20300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
	option channel '6'
	option band '2g'
	option htmode 'HT20'
	option cell_density '0'

config wifi-device 'radio1'
	option type 'mac80211'
	option phy 'phy0'
	option channel '1'
	option band '2g'
	option htmode 'HT20'
	option cell_density '0'

config wifi-iface 'wifinet3'
	option device 'radio1'
	option mode 'sta'
	option network 'wwan'
	option ssid 'SSID'
	option encryption 'psk2'
	option key '1234'

config wifi-iface 'wifinet4'
	option device 'radio0'
	option mode 'ap'
	option ssid 'SSID'
	option encryption 'psk2+ccmp'
	option key '1234'
	option wpa_disable_eapol_key_retries '1'
	option network 'lan'

"wifinet3" is an example, where the device connectes as a station/client ("=sta") to another Wifi.

full set of "wireless" parameters:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.