softether vpnclient via http proxy thru a ppp connection on linux

Instructions are already available here and here. Basically, read the official documentation here and establishing a connection to a server is the easy part.

The tricky part is, vpnclient/vpncmd on linux doesn’t yet manage your ip routes automatically, so it has to be done manually.

The point of this post is to mention that if you’re using http-proxy*, after a connection is established on vpncmd, don’t forget to make an exception for the http-proxy-server-ip when routing ‘default’ traffic to use the tunnel. If you don’t, the connection will loop, and softether will be cut off from the server. (This is annoyingly obvious in hindsight, which is why it is very easy to miss.)

So, before doing:

ip route add remote_ip via default_gateway dev ppp0 proto static
ip route del default
ip route add default via vpn_server_local_ip dev vpn_se

Make sure to first do:

ip route add http_proxy_ip via default_gateway dev ppp0

On the other hand, the client on Windows has a feature complete GUI, plus an integrated list of servers to connect to.

* a rare case, I think, but is the point of this whole affair in my use case, because I route my traffic to the ISPs own http proxy intended for GPRS connections, in order to bypass data-capping

Huawei 3G modem, usb_modeswitch, and udev rules

Ubuntu wouldn’t detect my trusty Huawei E1550 3G

I run lsusb and it’s listed.

I look at the Disks utility and the faux CD drive and SD slot is there.

What do I do?

Well, apparently, this particular gadget I have is called a USB composite device. Meaning, there are actually many “devices” in one USB connection, each accessible by switching to its USB mode. One mode is for the modem, another is for the faux cd-rom where the installer for its connection utility on Windows is located, and yet another is for the SD card slot controller.

The thing defaults to the faux cd-rom mode when first plugged in because it makes sense on Windows. Not on Ubuntu.

So what do we do?

First, check if we can make it switch to the modem mode. Run lsusb again.

It lists devices on vendorID:productID format. Huawei’s vendorID is 12d1. The faux cd-rom product ID is 1446. We want it to switch to 12d1:1001.

try this:

sudo usb_modeswitch -v 0x12d1 -p 0x1446 -M "55534243123456780000000000000011062000000101000100000000000000"

Run lsusb again. If it’s now listed as 12d1:1001, in less than a minute it should appear on the network manager indicator. Of course, we do not want to remember all that, so we make a config file on /etc/usb_modeswitch.d/ and call the file 12d1:1446.

$sudo nano "/etc/usb_modeswitch.d/12d1:1446"

We copy the following and Ctrl+Shift+V it to the nano editor. Ctrl+X, Y+Enter.

DefaultVendor= 0x12d1
 DefaultProduct=0x1446
 TargetVendor= 0x12d1
 TargetProductList="1001,1406,140b,140c,1412,141b,1433,14ac,1446"
 MessageContent="55534243123456780000000000000011062000000100000000000000000000"

On the Disks utility, Power Off Huawei MMC storage. Unplug the device and plug it back.

(Machines with correct udev rules should usb_modeswitch it automatically at this point, considering we already have the correct config file. But, no. In my case it didn’t.)

It will still be listed as 12d1:1446. What we want is to test the config file we just made.

sudo usb_modeswitch -c "/etc/usb_modeswitch.d/12d1:1446"

Run lsusb again. If it’s now listed as 12d1:1001, in less than a minute it should appear on the network manager indicator. Of course, we do not want to issue that command every time the device is plugged in. We want it to happen automatically.

udev is the program responsible for watching device changes and listing rules as to what such events would trigger. It’s located on /lib/udev/rules.d/40-usb_modeswitch.rules so we sudo gedit into that.

sudo gedit /lib/udev/rules.d/40-usb_modeswitch.rules

Notice something odd?

The format is like this (XXXX being the vendor ID and YYYY being the product ID):

ATTR{idVendor}=="XXXX", ATTR{idProduct}=="YYYY", RUN+="usb_modeswitch '%b/%k'"

Oddly, my machine’s udev rules follows that format except for Huawei entries, which it listed like this:

ATTR{idVendor}=="Huawei", ATTR{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"

Notice listing idVendor as Huawei instead of 12d1?

So I replaced every instance of ATTR{idVendor}=="Huawei" with ATTR{idVendor}=="12d1". Ctrl+H. Input preceding data accordingly. Save file.

On the Disks utility, Power Off Huawei MMC storage. Unplug the device and plug it back. It should now switch mode automatically.

Reference: http://ubuntuforums.org/showthread.php?t=2224305