Getting started with the Huawei K4203 in Linux

Getting started with the Huawei K4203 in Linux

Getting started with the Huawei K4203 in Linux

I recently bought a Huawei K4203 and I wanted a fully automated workflow on my laptop. So when I plug in the modem, it brings down the wireless and it connects to my home via openvpn. This is what you need to do to make it work…

  • Install the usbmodeswitch package. This is needed to switch the device from usb-storage mode to modem operation.
  • Create a file with the following rules in /etc/udev/rules.d/, mine is called 85-modem.rules. The Arch-wiki says the following thing about udev rules:

Udev rules written by the administrator go in /etc/udev/rules.d/, their file name has to end with .rules. The udev rules shipped with various packages are found in /usr/lib/udev/rules.d/. If there are two files by the same name under /usr/lib and /etc, the ones in /etc take precedence.

# Huawei k4203
ACTION=="add", ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f1c", RUN+="/usr/bin/usb_modeswitch -v 12d1 -p 1f1c -W -M 55534243123456780000000000000011062000000101000100000000000000"
ACTION=="add", SUBSYSTEM=="net", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1590", NAME="4gmodem", RUN+="SCRIPTDIR/"
ACTION=="remove", KERNEL=="4gmodem", RUN+="SCRIPTDIR/"

Change “SCRIPTDIR”  twice to fit your needs.

The interface is called “4gmodem”, but you’re free to pick your own name.

  • I assume you use the netctl package to control your network connections. Otherwise change the script or use netctl. The rfkill package is also needed.
  • Create two files and make them executable.
/usr/bin/rfkill block wifi 
/usr/bin/netctl restart 4gmodem-PROFILE 

# Optional 
/usr/bin/ping -c 1 -w 60 && 
/usr/bin/systemctl start openvpn@VPN_NAME.service

/usr/bin/systemctl stop openvpn@VPN_NAME.service
/usr/bin/rfkill unblock wifi
/usr/bin/ip link set WIRELESS_INTERFACE up

Configure the variables in the two files above to your needs.

If you don’t want to use the vpn part, remove this part.

  • My netctl profile used in de script above triggers the DHCP client when the device comes up. Also make sure you have a DHCP client installed on your system.
  • Make sure you load your new udev rules. Run the following command: sudo udevadm control --reload
  • Find out your modem’s internal ip address with ip r. In my case i could fill in this ip address in a browser to get to the modems settings panel.

That should be all!

Leave a Reply

Your email address will not be published. Required fields are marked *