# Setting up Huawei E220 3G modem through net.ppp0 initscript

## Arla

I've come across a couple of methods for getting my device up and running (see my thread on LinuxQuestions.org), and decided that using /etc/conf.d/net and /etc/init.d/net.ppp0, according to this gentoo-wiki.com article section, would probably be the best, and I am now trying to compose a suitable chat script.

This is the relevant part of /etc/conf.d/net. I don't know much about this kind of script, but I have been piecing together from different guides dealing with my device.

```
config_ppp0=( "ppp" )

link_ppp0="/dev/ttyUSB0"

username_ppp0='user'

password_ppp0='pass'

pppd_ppp0=( "updetach" "lock" "460800")

phone_number_ppp0=( "*99#" )

chat_ppp0=(

   'ABORT' 'BUSY'

   'ABORT' 'ERROR'

   'ABORT' 'NO ANSWER'

   'ABORT' 'NO CARRIER'

   'ABORT' 'NO DIALTONE'

   'ABORT' 'Invalid Login'

   'ABORT' 'Login incorrect'

   'TIMEOUT' '5'

   '' 'ATZ'

   'OK'   'AT+CGDCONT=1,"ip","data.tre.se"'

   'OK'   'ATE1V1&D2&C1S0=0+IFC=2,2'

   'OK'   'ATDT*99#'

   'TIMEOUT' '60'

   'CONNECT' ''

   'TIMEOUT' '5'

   '~--' ''

)
```

The output of /etc/init.d/net.ppp0 start with this configuration is as follows (from /var/log/messages):

```
Jun 12 22:44:23 ezekiel chat[28494]: abort on (BUSY)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (ERROR)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (NO ANSWER)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (NO CARRIER)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (NO DIALTONE)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (Invalid Login)

Jun 12 22:44:23 ezekiel chat[28494]: abort on (Login incorrect)

Jun 12 22:44:23 ezekiel chat[28494]: timeout set to 5 seconds

Jun 12 22:44:23 ezekiel chat[28494]: send (ATZ^M)

Jun 12 22:44:23 ezekiel chat[28494]: expect (OK)

Jun 12 22:44:23 ezekiel chat[28494]: ATZ^M^M

Jun 12 22:44:23 ezekiel chat[28494]: OK

Jun 12 22:44:23 ezekiel chat[28494]:  -- got it 

Jun 12 22:44:23 ezekiel chat[28494]: send (AT+CGDCONT=1,"ip","data.tre.se"^M)

Jun 12 22:44:24 ezekiel chat[28494]: expect (OK)

Jun 12 22:44:24 ezekiel chat[28494]: ^M

Jun 12 22:44:24 ezekiel chat[28494]: AT+CGDCONT=1,"ip","data.tre.se"^M^M

Jun 12 22:44:24 ezekiel chat[28494]: OK

Jun 12 22:44:24 ezekiel chat[28494]:  -- got it 

Jun 12 22:44:24 ezekiel chat[28494]: send (ATE1V1&D2&C1S0=0+IFC=2,2^M)

Jun 12 22:44:24 ezekiel chat[28494]: expect (OK)

Jun 12 22:44:24 ezekiel chat[28494]: ^M

Jun 12 22:44:24 ezekiel chat[28494]: ATE1V1&D2&C1S0=0+IFC=2,2^M^M

Jun 12 22:44:24 ezekiel chat[28494]: OK

Jun 12 22:44:24 ezekiel chat[28494]:  -- got it 

Jun 12 22:44:24 ezekiel chat[28494]: send (ATDT*99#^M)

Jun 12 22:44:24 ezekiel chat[28494]: timeout set to 60 seconds

Jun 12 22:44:24 ezekiel chat[28494]: expect (CONNECT)

Jun 12 22:44:24 ezekiel chat[28494]: ^M

Jun 12 22:44:24 ezekiel chat[28494]: ATDT*99#^M^M

Jun 12 22:44:24 ezekiel chat[28494]: CONNECT

Jun 12 22:44:24 ezekiel chat[28494]:  -- got it 

Jun 12 22:44:24 ezekiel chat[28494]: send (^M)

Jun 12 22:44:24 ezekiel chat[28494]: timeout set to 5 seconds

Jun 12 22:44:24 ezekiel chat[28494]: expect (~)

Jun 12 22:44:24 ezekiel chat[28494]: ^M

Jun 12 22:44:29 ezekiel chat[28494]: alarm

Jun 12 22:44:29 ezekiel chat[28494]: send (^M)
```

... which is repeated with intervals of 30 seconds, until I interrupt the initscript.

ifconfig ppp0 gives nothing while the initscript is running.

Any advices on how to improve the script so that it actually connects?

Thanks.

----------

## Akhouk

Are there no ppp log entries at all? It would seem that the CHAT is going ok until it tries to establish the PPP over the link.

----------

## Arla

Where would "ppp log entries" take place? Does ppp have a log on its own, or are they supposed to be in /var/log/messages, too? grep ppp /var/log/messages gives nothing.

----------

## Akhouk

Yeah should be in /var/log/message probably. Could be somewhere else - depends on your setup.

It just seems like ppp is starting to failing and there must be a reason.

What kernel modules do you have loaded ??

----------

## Arla

 *Akhouk wrote:*   

> Yeah should be in /var/log/message probably. Could be somewhere else - depends on your setup.
> 
> It just seems like ppp is starting to failing and there must be a reason.

 

Apparently there's a ppp.log in /var/log (I don't understand how I could not see that before), but it has only the same chat output as in /var/log/messages.

 *Akhouk wrote:*   

> What kernel modules do you have loaded ??

 

These are probably the relevant loaded modules.

```
ppp_async               7424  0 

ppp_generic            15892  1 ppp_async

slhc                    5120  1 ppp_generic

crc_ccitt               1920  1 ppp_async

option                  8448  0 

usbserial              25064  1 option
```

----------

## hujuice

My /etc/conf.d/net is a bit different and the relevant difference is:

```
pppd_ppp0=(

        "updetach"

        "debug"

        "noauth"

        "defaultroute"

        "usepeerdns"

        "921600"

        "crtscts"

        "novj"

        "logfile /var/log/WIND-pppd.log"

)
```

Obviously, I don't remember the default values of the pppd daemon ('man pppd' is very exhaustive) and some of that rows are redundant, but I think that 'noauth' and 'novj' are needed options.

The same configuration works with all the italian mobile providers.

Regards,

HUJuice

----------

## Arla

hujuice> I'm very thankful for your help, but unfortunately, I don't have access to a dongle anymore, so I don't know how long it will take before I can try out your suggestion. (I borrowed a friend's device, to try and see if it was worth getting one of my own, but I do not any longer have that possibility, for irrelevant reasons.)

----------

## Arla

Now I've got hold on the same device again, and interesting things are happening.

I've been testing different values for pppd_ppp0, and what I found is that, if "usepeerdns" is one of them, then the output of ping will change from

```
PING dn.se (62.119.189.4) from 10.143.115.89 ppp0: 56(84) bytes of data.

^C

--- dn.se ping statistics ---

5 packets transmitted, 0 received, 100% packet loss, time 4000ms
```

to

```
ping: unknown host dn.se
```

Also, eth0 won't work when ppp0 is active with "usepeerdns" specified.

man ppp0 says:

```
usepeerdns

       Ask  the  peer  for up to 2 DNS server addresses.  The addresses

       supplied by the peer (if any) are passed to  the  /etc/ppp/ip-up

       script in the environment variables DNS1 and DNS2, and the envi‐

       ronment variable USEPEERDNS will be set to 1.  In addition, pppd

       will  create  an /etc/ppp/resolv.conf file containing one or two

       nameserver lines with the address(es) supplied by the peer.
```

I don't understand anything useful from it, but some of you might.

Still, of course, enormously thankful for help!

----------

## hujuice

mmhh...

The DNS (Domain Name Service) matches human host names (eg dn.se) into IP addresses (eg 62.119.189.4), the ones able to route the traffic over the network (think to telephone numbers and friend names in your address book).

The "unknown host" response usually means that your computer cannot resolv the hostname (dn.se) into any IP address.

The /etc/resolv.conf file contains a couple of DNS servers and the usepeerdns option let your pppd service  automagically write that file.

I think that your ISP don't give up a valid DNS service, so the usepeerdns option is not good for you.

You can post the content of /etc/resolv.conf while you're connected to be sure about it.

Anyway, you can use any valid, public DNS.

A good idea is to use the OpenDNS addresses, since someone says that they've excellent performance.

To do this, disable the 'usepeerdns' feature and add a this line:

```
dns_servers_ppp0=( "208.67.222.222" "208.67.220.220")
```

Something more.

If you enable the "debug" option and the "logfile /var/log/pppd.log" option, you can try to post it or to understand what's happening reading that logfile.

Regards,

HUjuice

----------

