How to use Fedora 37 machine to bridge two wifi cards

I have 2 USB wifi cards on my fedora machine.
I want to achieve:
wifi card 1 connects to the router and has internet.
use wifi card 2 as a hotspot to create a wifi network ( that is different to the wifi that wifi card 1 connects to) .
fedora machine shares the internet connection from card 1 to devices connected to wifi card 2.
devices connected to the wifi that is created by card 2 can connect to the internet.
what I tried: connect wifi card 1 to the internet, turn on hotspot in the network settings, and turn on ip forwarding by editing /etc/sysctl.conf
the results are:
fedora machine can access the internet,
devices are able to connect to the wifi that is created by card 2, but are not able to access the internet.

Assuming the default Fedora setup with NetworkManager and firewalld.
For the downstream connection, change IPv4/IPv6 method to sharing and enable NAT66 if necessary:

# List connections
nmcli connection show

# Downstream IPv4 sharing
nmcli connection modify DOWNSTREAM_CONNECTION \
    ipv4.method shared \

# Downstream IPv6 sharing
nmcli connection modify DOWNSTREAM_CONNECTION \
    ipv6.method shared \
    ipv6.addresses fd00:11::1/64

# NAT66
sudo firewall-cmd --permanent --add-rich-rule="rule family=ipv6 masquerade"
sudo firewall-cmd --reload
1 Like