[TIP] MMS behind Wifi
-
Hello
this is a little hack I have done to be able to send/receive MMS on my FP5 running 24.04.1.1 stable. Skills needed: some terminal experience, use of editor, sudo, basic networking knowledge, be able to read the system journal. If you are a total newbie in Linux, it may be better to abstain to attempt the following.
Note that if your phone supports 2 cellular links, mine does not and so I have no idea if it will work in your case.
Preliminary: find if your system behaves like mine by running the (very slow) command:
journalctl | grep lomiri-download-manager | grep TimeoutErrorif you find lines looking like this:
janv. 05 18:49:27 ubuntu-phablet lomiri-download-manager[21916]: E20260105 18:49:27.165113 21916 file_download.cpp:527] Download ID{ 03d5e06553d8471085141080bcff97a1 } http://213.228.3.45/mms.php?uZmaWepeEfC3hAAmufq69A ERROR::Network error TimeoutError: the connection to the remote server timed outthen the problem is that the provider is blocking access to its network (here 213.228.3.0/24) when not accessing it from the cellular link (their own network). In this case, the following hack could apply to you.
First step: add to the system the capability to change the network manager configuration.
cat /etc/systemd/system/etc-NetworkManager-dispatcher.d.mount [Unit] Description=Mount unit for etc/NetworkManager/dispatcher.d DefaultDependencies=no Requires=system.slice dev-sda17.device -.mount Conflicts=umount.target Before=umount.target local-fs.target Before=network-pre.service Wants=network-pre.service [Mount] Where=/etc/NetworkManager/dispatcher.d What=/userdata/system-data/etc/NetworkManager/dispatcher.d Options=rw,relatime,upperdir=/userdata/system-data/etc/NetworkManager/dispatcher.d,lowerdir=/etc/NetworkManager/dispatcher.d,workdir=/userdata/system-data/tmp Type=overlay [Install] WantedBy=network.targetcreate this file with sudo.
then:
sudo mkdir -P /userdata/system-data/etc/NetworkManager/dispatcher.d sudo mkdir /userdata/system-data/tmpthen add in our dispatcher.d directory the file that will call our script:
cat /userdata/system-data/etc/NetworkManager/dispatcher.d/99routechange #!/bin/sh -e interface=$1 status=$2 #logger "99routechange: ($interface): $status" /usr/bin/python3 /home/phablet/bat/networkchange.py $interface $status(you will have to create the preceding file using sudo of course)
create our work directory
mkdir ~/batcreate the script that will ask to the system the network configuration when a change is detected and run the commands adding the necessary routes to the provider:
cat ~/bat/networkchange.py import os import subprocess import sys DEFAULT_ROUTE = 'default via' if __name__ == '__main__': interface = sys.argv[1] status = sys.argv[2] with open('/home/phablet/bat/status_network.txt', 'w') as f: f.write(f'network {interface} : {status}') with subprocess.Popen(['ip', 'route'], stdout=subprocess.PIPE, universal_newlines=True) as ipr: lines = ipr.communicate()[0].splitlines() lig1 = lines[0] lig2 = lines[1] lig3 = lines[2] if lig1.startswith(DEFAULT_ROUTE) and lig2.startswith(DEFAULT_ROUTE) and not lig3.startswith(DEFAULT_ROUTE): if lig1.find('wlan') != -1: idx = lig2.find(' dev ') + 5 cellular_interface = lig2[idx:][0:lig2[idx+1:].find(' ')+1] with open('/home/phablet/bat/cmd_to_run', 'r') as f: lines = f.readlines() with open('/home/phablet/bat/status_network.txt', 'w+') as flog: for l in lines: new_line = l.replace('{cellular_interface}', cellular_interface) flog.write(new_line) os.system(new_line)then add the specific to your configuration route commands, example for my case follows:
cat /home/phablet/bat/cmd_to_run # cellular_interface is replaced by the caller ip route add 213.228.2.0/24 dev {cellular_interface} proto static metric 100 ip route add 213.228.3.0/24 dev {cellular_interface} proto static metric 100 # this is the address for mms.free.fr ip route add 212.27.40.0/24 dev {cellular_interface} proto static metric 100Please note that these IP addresses will not be correct unless you happen to use Freemobile (my provider). Otherwise, you will have to replace the IP addresses in the first lines by the specific addresses for your provider that you will find by using
journalctl | grep lomiri-download-manager | grep TimeoutErrorNote that you may have to add more lines if your provider has many networks used.
Also, do NOT add addresses server by server, use network ranges (here /24 means 256 consecutive IP addresses) else you will spend your life trying to cover all the servers used by your provider. In the case of Freemobile, at the moment Free seems to use 2 /24 ranges. Maybe there are some that have escaped me.and for mms sending, for my provider the dns name for the server is found in the cellular config, you will find the IP address by using dig:
dig mms.free.fr(replace 'mms.free.fr' by the name of your provider mms server)
It's possible that the configuration may be different for your provider.
Note: you MUST use IP addresses, the symbolic names will NOT work; for my use here I replace mms.free.fr by 212.27.40.0/24.
It's quite possible that your provider uses also symbolic names (not raw IP addresses like Freemobie) for downloading MMS, in this case you should also find an appropriate IP range using dig like I did for uploading.Finally, enable the whole systemd configuration.
sudo systemctl daemon-reload sudo systemctl enable etc-NetworkManager-dispatcher.d.mount sudo systemctl start etc-NetworkManager-dispatcher.d.mountand you should be able to send/receive mms when wifi is activated.
I hope I did not forget anything.
Note that testing has been minimal
but the main risk is that it will not work.The configuration resists reboots.
When this merge-request will land and be added to the stable release you use, then you will be able to disable this hack, that you will do by running
sudo systemctl stop etc-NetworkManager-dispatcher.d.mount sudo systemctl disable etc-NetworkManager-dispatcher.d.mount sudo rm /etc/systemd/system/etc-NetworkManager-dispatcher.d.mount sudo systemctl daemon-reloadUntil then, happy MMS with wifi enabled !