Mobilfunkrouter (Alcatel L850V) mit FreeBSD
Robin (Diskussion | Beiträge) (→Konfiguration FreeBSD) |
Robin (Diskussion | Beiträge) (→Konfiguration Alcatel onetouch L850V 4G+) |
||
(Eine dazwischenliegende Version von einem Benutzer wird nicht angezeigt) | |||
Zeile 85: | Zeile 85: | ||
Die ProductID wurde von 0xf000 nach 0x0195 umgeschaltet: |
Die ProductID wurde von 0xf000 nach 0x0195 umgeschaltet: |
||
− | ugen3.2: <Alcatel MobileBroadBand> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) |
+ | ugen3.2: <Alcatel MobileBroadBand> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) |
− | |||
bLength = 0x0012 |
bLength = 0x0012 |
||
bDescriptorType = 0x0001 |
bDescriptorType = 0x0001 |
||
Zeile 243: | Zeile 243: | ||
$cmd 06420 nat 1 ip4 from any to any out via $pif # NAT for outgoing ipv4 packets |
$cmd 06420 nat 1 ip4 from any to any out via $pif # NAT for outgoing ipv4 packets |
||
# |
# |
||
− | # $cmd 04500 check-state # check dynamic installed rules |
||
# |
# |
||
− | $cmd 06450 allow ip4 from any to any xmit $pif # keep-state # allow connections from pppoe if |
+ | $cmd 06450 allow ip4 from any to any xmit $pif # keep-state # |
# |
# |
||
# |
# |
Aktuelle Version vom 2. Juni 2020, 14:18 Uhr
Konfiguration eines Mobilfunkrouters mit FreeBSD und einem LTE-Stick "Alcatel onetouch L850V 4G+"
USB-Mobilfunksticks werden in der Regel aus Sicht des Betriebssystems entweder über eine serielle Schnittstelle und AT-Kommandos angesprochen oder sie stellen eine Ethernet Schnittstelle bereit. Über DHCP kann eine IPv4 Adresse konfiguriert werden. IPv6 wird mittels Stateless Address Autoconfiguration (Router Advertisements) konfiguriert.
[Bearbeiten] Konfiguration Alcatel onetouch L850V 4G+
Der LTE-Stick Alcatel onetouch L850V 4G+ stellt eine Ethernet Schnittstelle zur Verfügung und hat ein eigenes Web-Interface.
Leider befinden sich die meisten Stick nicht per Default in diesem Modus. Per default stellen sie einen USB-Speicherstick dar wo sich die Windows-Software zur Installation befindet. Diese Software schaltet unter Windows den Modus des Sticks um.
Diese Umschaltung erfolgt unter FreeBSD (und Linux) mit dem Tool usb_modeswitch.
Das Tool kann mit dem Befehl: "pkg install usb_modewitch" installiert werden.
Nach Einstecken des Sticks stellt sich dieser so dar:
Auszug aus dmesg:
ugen3.2: <Alcatel MobileBroadBand> at usbus3 umass0 on uhub3 umass0: <Mass Storage> on usbus3 umass0: SCSI over Bulk-Only; quirks = 0x4000 umass0:2:0: Attached to scbus2 da0 at umass-sim0 bus 0 scbus2 target 0 lun 0 da0: <ONETOUCH ESTORIL 2.31> Removable Direct Access SCSI-2 device da0: 40.000MB/s transfers da0: Attempt to query device size failed: NOT READY, Medium not present da0: quirks=0x2<NO_6_BYTE> cd0 at umass-sim0 bus 0 scbus2 target 0 lun 1 cd0: <ONETOUCH ESTORIL 2.31> Removable CD-ROM SCSI-2 device cd0: 40.000MB/s transfers cd0: 50MB (25600 2048 byte sectors) cd0: quirks=0x10<10_BYTE_ONLY>
usbconfig ugen3.2: <Alcatel MobileBroadBand> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
bzw.:
usbconfig dump_device_desc ugen3.2: <Alcatel MobileBroadBand> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) bLength = 0x0012 bDescriptorType = 0x0001 bcdUSB = 0x0201 bDeviceClass = 0x0000 <Probed by interface class> bDeviceSubClass = 0x0000 bDeviceProtocol = 0x0000 bMaxPacketSize0 = 0x0040 idVendor = 0x1bbb idProduct = 0xf000 bcdDevice = 0x0228 iManufacturer = 0x0001 <Alcatel> iProduct = 0x0002 <MobileBroadBand> iSerialNumber = 0x0003 <0123456789ABCDEF> bNumConfigurations = 0x0001
Mit folgendem Befehl kann der Stick umgeschaltet werden:
usb_modeswitch -v 0x1bbb -p 0xf000 -c /usr/local/share/usb_modeswitch/1bbb:f000 Look for target devices ... No devices in target mode or class found"Alcatel onetouch L850V 4G+" Look for default devices ... Found devices in default mode (1) Access device 002 on bus 003 Get the current device configuration ... Current configuration number is 1 Use interface number 0 with class 8 Use endpoints 0x01 (out) and 0x81 (in) Looking for active drivers ... OK, driver detached Set up interface 0 Use endpoint 0x01 for message sending ... Trying to send message 1 to endpoint 0x01 ... OK, message successfully sent Read the response to message 1 (CSW) ... Response reading failed (error -9) Device is gone, skip any further commands -> Run lsusb to note any changes. Bye!
Die ProductID wurde von 0xf000 nach 0x0195 umgeschaltet:
ugen3.2: <Alcatel MobileBroadBand> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) bLength = 0x0012 bDescriptorType = 0x0001 bcdUSB = 0x0201 bDeviceClass = 0x0000 <Probed by interface class> bDeviceSubClass = 0x0000 bDeviceProtocol = 0x0000 bMaxPacketSize0 = 0x0040 idVendor = 0x1bbb idProduct = 0x0195 bcdDevice = 0x0228 iManufacturer = 0x0001 <Alcatel> iProduct = 0x0002 <MobileBroadBand> iSerialNumber = 0x0003 <0123456789ABCDEF> bNumConfigurations = 0x0001
Generell erfolgt das Ansteuern von USB-Tethering Geräten über drei Verfahren:
https://www.freebsd.org/doc/handbook/network-usb-tethering.html
- Android™ devices generally use the urndis(4) driver. - Apple® devices use the ipheth(4) driver. - Older devices will often use the cdce(4) driver.
Der "Alcatel onetouch L850V 4G+" wird mittels dem urndis Treiber angesprochen. Dafür muß das Modul if_urndis geladen werden:
kldload if_urndis
dann steht die Ethernet Schnittstelle zur Verfügung.
ue0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 ether ee:3a:f2:5f:b3:55 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Mit DHCP kann eine IP-Adresse angefordert werden (IPv6 geht z. Z. mit O2 SIM-Karte nicht):
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 ether ee:3a:f2:5f:b3:55 inet6 fe80::ec3a:f2ff:fe5f:b355%ue0 prefixlen 64 scopeid 0x4 inet 192.168.1.145 netmask 0xffffff00 broadcast 192.168.1.255 nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
Das Webinterface des LTE-Sticks kann über die Adresse 192.168.1.1 erreicht werden.
Je nachdem ob der Mobilfunkprovider IPv6 unterstützt gibt es auch eine IPv6 Adresse per stateless Autoconfiguration.
Beispiel bei Linux (Mit Congstar/Telekom SIM-Karte):
enp0s22f2u1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.137 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::5de4:43ff:3bc6:5df6 prefixlen 64 scopeid 0x20<link> inet6 2a01:598:b900:d225:ce81:ac1c:c048:1b60 prefixlen 64 scopeid 0x0<global> ether 5a:b9:ef:c3:80:5a txqueuelen 1000 (Ethernet) RX packets 15244 bytes 14222973 (13.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13772 bytes 4661913 (4.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[Bearbeiten] Konfiguration FreeBSD
Damit der Router für ein kleines LAN eingesetzt werden kann soll noch NAT für IPv4 und IPv6-to-IPv6 NETWORK PREFIX TRANSLATION (NPTv6) für IPv6 konfiguriert werden. Dazu soll der FreeBSD Paketfilter soll folgendermassen konfiguriert werden:
- NAT für IPv4 - IPv6-to-IPv6 NETWORK PREFIX TRANSLATION (NPTv6)
Ausschnitt aus der Manpage von ipfw:
IPv6-to-IPv6 NETWORK PREFIX TRANSLATION (NPTv6)
ipfw supports in-kernel IPv6-to-IPv6 network prefix translation as de- scribed in RFC6296. The kernel module ipfw_nptv6 should be loaded or kernel should has options IPFIREWALL_NPTV6 to be able use NPTv6 transla- tor.
+-----------+ +---------+ | |192.168.1.1 192.168.1.2 | |192.168.2.1 +-----+ Internet----| LTE-Stick |------------------------------| FreeBSD |----------------| LAN | | | /64 IPv6 Prefix | |fd00::/8 +-----+ +-----------+ +---------+
Ob das IPv6-to-IPv6 NETWORK PREFIX TRANSLATION wie erwartet funktioniert muß getestet werden.
Infos zu NPTv6 (network prefix translation for IPv6) module for ipfw:
https://reviews.freebsd.org/D6420
Entwurf für IPv4 NAT und NPTv6 (NPTv6 ungetestet)
cat /etc/rc.firewall #!/bin/sh - # ################ Start of IPFW rules file ############################### # Flush out the list before we begin. ipfw -q -f flush # # Set rules command prefix cmd="ipfw -q add" pif=ue0 lanif=fxp0 skiptonat="skipto 06420" # # # Grundsaetzlich bei NAT: # eingehende Pakete (Internet -> LAN) 1. NAT anwenden 2. FW Regeln anwenden # ausgehende Pakete (LAN -> Internet) 1. FW Regeln anwenden 2. NAT anwenden # # $cmd 00100 allow ip from any to any via lo0 # allow loopback # # # reassemble packet fragments, only ipv4! # $cmd reass all from any to any in # breaks ipv6! $cmd 00150 reass ip4 from any to any in # ipv4 only! else packet/fragment loss after NAT # # # NPTv6 ipfw nptv6 MOBILF create int_prefix fd01:db8:4a72:6f65:: ext_if ue0 prefixlen 64 ipfw add allow icmp6 from any to any icmp6types 135,136 ipfw add nptv6 MOBILF ip6 from any to any # # # LAN if router allow ipv4 $cmd 00160 allow ip4 from any to any via $lanif # # $cmd 00165 allow ip6 from any to any via $lanif # # # # WAN IF $cmd 00170 allow ip4 from 192.168.1.0/24 to any via $pif # no NAT for this network # # $cmd 00180 allow ip6 from any to any via $pif # allow ipv6 # # # $cmd 00400 allow ip4 from any to any dst-port 22 proto tcp in via $pif keep-state $cmd 00410 allow ip4 from any to any dst-port 80 proto tcp in via $pif keep-state $cmd 00420 allow ip4 from any to any dst-port 443 proto tcp in via $pif keep-state # # ipfw -q nat 1 config if $pif unreg_only reset # NAT rule # # $cmd 04110 nat 1 ip4 from any to any in via $pif # NAT for incoming ipv4 packets # $cmd 04120 check-state # check state for incoming packets / SIP traffic $cmd 04130 deny log ip4 from any to any 5060 in via $pif # deny SIP for non dynamic rules # # outbound packets $cmd 04200 $skiptonat ip4 from any to any 5060 out via $pif keep-state # allow outgoing traffic sip port 5060 $cmd 04210 $skiptonat ip4 from any to any out via $pif keep-state # allow all outgoing ipv4 traffic # # $cmd 06420 nat 1 ip4 from any to any out via $pif # NAT for outgoing ipv4 packets # # $cmd 06450 allow ip4 from any to any xmit $pif # keep-state # # # $cmd 06460 allow ip4 from any to any in via $pif # $cmd 06462 allow ip4 from any to any out via $pif # # # Allow ipv4 all $cmd 65534 allow ip4 from any to any