Eu configurei meu modem LTE com NetworkManager/ModemManager e está funcionando bem. Também configurei o Wifi como ponto de acesso no NetworkManager com DHCP.
Mas como posso compartilhar o acesso à Internet do modem LTE via Wifi? Habilitei o encaminhamento de IP ( echo 1 > /proc/sys/net/ipv4/ip_forward
), o que mais há?
# ifconfig
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:12946 errors:0 dropped:0 overruns:0 frame:0
TX packets:12946 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1297231 (1.2 MiB) TX bytes:1297231 (1.2 MiB)
wlan0 Link encap:Ethernet HWaddr E8:4F:25:DD:BD:51
inet addr:10.42.0.1 Bcast:10.42.0.255 Mask:255.255.255.0
inet6 addr: fe80::ea4f:25ff:fedd:bd51/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:12101 (11.8 KiB)
wwan0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:100.72.254.176 P-t-P:100.72.254.176 Mask:255.255.255.224
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:1808 errors:0 dropped:0 overruns:0 frame:0
TX packets:2176 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:356293 (347.9 KiB) TX bytes:261384 (255.2 KiB)
# ip route
default via 100.72.254.177 dev wwan0 metric 700
10.42.0.0/24 dev wlan0 scope link src 10.42.0.1 metric 600
100.72.254.160/27 dev wwan0 scope link src 100.72.254.176 metric 700
O DHCP para o Wifi é feito pelo NetworkManager iniciando o dnsmasq com parâmetros padrão:
# ps -eF | grep dnsmasq
nobody 1104 606 0 1285 2444 0 09:05 ? 00:00:00 /usr/bin/dnsmasq --conf-file=/dev/null --no-hosts --keep-in-foreground --bind-interfaces --except-interface=lo --clear-on-reload --strict-order --listen-address=10.42.0.1 --dhcp-range=10.42.0.10,10.42.0.254,60m --dhcp-lease-max=50 --dhcp-leasefile=/var/lib/NetworkManager/dnsmasq-wlan0.leases --pid-file=/var/run/nm-dnsmasq-wlan0.pid --conf-dir=/etc/NetworkManager/dnsmasq-shared.d
ref NetworkManager e intervalo de endereços dnsmasq dhcp ).
# cat /etc/NetworkManager/system-connections/ap.nmconnection
[connection]
id=ap
uuid=3205b229-8c4d-4766-8d63-bcd949d03321
type=wifi
autoconnect=false
interface-name=wlan0
[wifi]
band=bg
channel=1
mode=ap
ssid=MySSID
[wifi-security]
group=ccmp;
key-mgmt=wpa-psk
pairwise=ccmp;
proto=rsn;
psk=MyPSK
[ipv4]
method=shared
[ipv6]
addr-gen-mode=stable-privacy
method=ignore
[proxy]
Um colega sugeriu https://github.com/oblique/create_ap . Tentei as opções NAT e bridge, mas ambas falharam.
NAT:
# create_ap -w 2 wlan0 wwan0 APTest 12345678
WARN: brmfmac driver doesn't work properly with virtual interfaces and
it can cause kernel panic. For this reason we disallow virtual
interfaces for your adapter.
For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
Config dir: /tmp/create_ap.wlan0.conf.XX59Vdf8
PID: 537195
Network Manager found, set wlan0 as unmanaged device... [46988.754925] ieee80211 phy1: brcmf_set_pmk: failed to change PSK in firmware (len=0)
[46988.784848] ieee80211 phy1: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
[46988.792027] ieee80211 phy1: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
DONE
Sharing Internet using method: nat
iptables v1.8.7 (legacy): unknown option "--to-ports"
Try `iptables -h' or 'iptables --help' for more information.
Doing cleanup.. done
Ponte:
# create_ap -w 2 -m bridge wlan0 wwan0 APTest 12345678
WARN: brmfmac driver doesn't work properly with virtual interfaces and
it can cause kernel panic. For this reason we disallow virtual
interfaces for your adapter.
For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
Config dir: /tmp/create_ap.wlan0.conf.XXgGPNON
PID: 540585
Network Manager found, set wlan0 as unmanaged device... DONE
Sharing Internet using method: bridge
Create a bridge interface... ip: RTNETLINK answers: Operation not supported