I use a Raspberry Pi 4B running Raspberry Pi OS 11 (Buster I guess) as a media center. I would like to install OpenWrt 21.02 in the Pi. However, I do not want to lose my media center.
What I think could be a viable solution is to run the media center stuff in the host side and run OpenWrt in a container or VM.
eth0: Built in ethernet port of the Pi. This will be the LAN port. eth1: USB connected ethernet port. This will be the WAN port. wlan0: Built in WiFi module of the Pi. This will be used by the media center. wlan1: USB connected WiFi module. This will be used by OpenWrt.
OpenWrt container will do all router stuff.
The host will be disconnected from OpenWrt. The host will connect to the network of the virtual router ONLY by WiFi. (wlan0 ---> wlan1)
I think this possible, but I have no idea how.
Any help is appreciated.
PS: I cannot explain stuff well. Sorry for inconvenience.
PS: Bad drawing. Hopefully good enough for illustration.
Well, I tried. Debootstrap in OpenWrt, and then xorg and kodi. It spits out some "get_ptys" error.
Also an uneducated guess that OpenWrt is not optimized enough for graphics stuff, like graphics drivers. Raspbian is the official OS of the Pi, so its the best choice.
In Teleport the Wi-Fi section, it shows how to transfer a device from the host to the container. This makes it unaccessible from the host and accessible from the container. That is indeed what I want.
If I do the same for eth0, eth1 and wlan1 I think I achieve the above mentioned topology from a hardware perspective?
I do not have access to the pi right now, so can't test it atm.
$ ip netns help
Usage: ip netns list
ip netns add NAME
ip netns attach NAME PID
ip netns set NAME NETNSID
ip [-all] netns delete [NAME]
ip netns identify [PID]
ip netns pids NAME
ip [-all] netns exec [NAME] cmd ...
ip netns monitor
ip netns list-id [target-nsid POSITIVE-INT] [nsid POSITIVE-INT]
NETNSID := auto | POSITIVE-INT
$ ip li help
Usage: ip link add [link DEV | parentdev NAME] [ name ] NAME
[ txqueuelen PACKETS ]
[ address LLADDR ]
[ broadcast LLADDR ]
[ mtu MTU ] [index IDX ]
[ numtxqueues QUEUE_COUNT ]
[ numrxqueues QUEUE_COUNT ]
type TYPE [ ARGS ]
ip link delete { DEVICE | dev DEVICE | group DEVGROUP } type TYPE [ ARGS ]
ip link set { DEVICE | dev DEVICE | group DEVGROUP }
[ { up | down } ]
[ type TYPE ARGS ]
[ arp { on | off } ]
[ dynamic { on | off } ]
[ multicast { on | off } ]
[ allmulticast { on | off } ]
[ promisc { on | off } ]
[ trailers { on | off } ]
[ carrier { on | off } ]
[ txqueuelen PACKETS ]
[ name NEWNAME ]
[ address LLADDR ]
[ broadcast LLADDR ]
[ mtu MTU ]
[ netns { PID | NAME } ]
...
Yeah it's called network namespace. e.g. ip netns add <openwrt> then ip li set eth0 netns <openwrt>
I was able to get eth1 and wlan1 in the container. I was also able to figure out my WAN connection. I can now ping IPs and domains. I successfully ran opkg update from the WAN connection.
This is what I have achieved so far:
# Set Docker image type.
DKIMG='openwrtorg/rootfs:aarch64_cortex-a53-openwrt-21.02'
# Create OpenWrt docker container if not created.
if [ "$(docker ps -a | grep $DKIMG)" = "" ]
then
docker create --cap-add NET_ADMIN --cap-add NET_RAW --hostname RasPi-4B --name openwrt --network none $DKIMG
fi
# Start OpenWrt docker container.
docker start openwrt
# Get container PID for network namespace.
NSPID=$(docker inspect -f '{{.State.Pid}}' openwrt)
# Add ethernet ports.
ip l set dev eth1 netns $NSPID
# Add Wi-Fi devices.
iw phy phy1 set netns $NSPID
Now I want to get my wifi to atleast brodcast its SSID. But, I cannot seem to be able to figure out how.
Firstly I installed the following packages: kmod-mac80211, wireless-tools
/etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option path <NOT SURE IF I AM SAFE TO SHOW THIS IDK>
option band '2g'
option cell_density '0'
option htmode 'HT20'
option channel 'auto'
config wifi-iface 'wifi_lan'
option device 'radio0'
option mode 'ap'
option encryption 'psk2+ccmp'
option key 'someRandomPassword'
option ssid 'OpenWrtDocker'
I do not see my Wi-Fi SSID being brodcasted.
Also, I got radio0.path from the config files when OpenWrt baremetally ran on the Pi. Maybe the path is wrong?? Or maybe the other config is wrong?
How am I supposed to know then which is right?
I just made a virtual machine and used the official OpenWRT images. I used a virt manager with the USE of KVM for this. Remember to use Raspberry Pi os in the latest version, version 64bit.
Okay so my lan is working, dhcp working, but no internet connection...
I do not know why, the container does have internet connection. I can ping the WAN gateway, and all IPs and domains. But I cannot even ping the gateway if I am connected to LAN via Wi-Fi.
BTW I can SSH into the container/router, and can access LuCI.
If anybody knows what is going on please help.
Thanks.