[Question] How to enable cellular connection using terminal?



  • Introduction

    Hi, I wrote few scripts that reconnect user to configured VPN in specific situations e.g. when wifi is off it enables it.
    I would like to do same thing with cellular data. Unfortunately I can't find out what is the command for it. I tired some nmcli commands with no success.

    Question

    Is there possibility to enable cellular data using terminal without sudo?

    My Tries

    1

    nmcli device connect ril_0
    
    Error: Filed to add/activate new connection: Message recipient disconnected from message bus without replying
    

    2

    nmcli connection up ifname ril_0
    
    Error: Connection activation filed: The device 'ril_0' has no connection available for activation
    

    3
    When you type nmcli c show the gsm is assigned to device field and it looks like something that shouldn't be shared in Internet 😉

    nmcli c up /xxxxxxxxxxxx/xxxxx
    
    Error: connection activation filed: No suitable device found for this connection.
    

    4

    nmcli monitor
    

    Then I clicked switch to enable cellular data, output:

    ril_0: disconnected
    Networkmanager is now in the 'connecting state'
    ril_0: connecting (prepare)
    ril_0: using connection '/xxxxxxxxxx/xxxxx'
    rmnet0: device removed
    Connectivity is now 'full'
    '/xxxxxxxxxxxxxx/xxxxxx' is now primary connection
    Networkmanager is now in the 'connected' state 
    ril_0: connected
    

    So how we can do all above steps manually?

    Solution

    here will be the solution
    

    First post changelog

    • 2020.08.21 - issue creation.


  • @BigB Hi, afaik NetworkManager doesn't manage cellular connection in UT, you should probably try with ofono / rild.



  • @Capsia said in [Question] How to enable cellular connection using terminal?:

    ofono / rild

    Hi, interesting too, my cell phone loses the connection to the cell network.



  • @Capsia Thank You! 🙂

    I'll continue searching but now with proper tools.
    For more advanced users maybe this or this will help - Especially this part of article: "Here is an example script of modem initialization:(...)"