# 3G and PPP Configuration



## Amzo (Dec 22, 2011)

I have been having trouble getting my 3G device to work under FreeBSD. The device is detected and I can communicate directly with the device, I just can't seem to get it to connect.

The device shows as /dev/cuaU0.2 and I have this config in /etc/ppp/ppp.conf


```
default: 
   set log Phase Chat LCP IPCP CCP tun command 

   set device /dev/cuaU0.2 # I have so maybe you will have 0 

   set speed 115 200 
   set dial "ABORT BUSY ABORT NO \\ sCARRIER TIMEOUT 5 \"\" AT OK-AT-OK ATE1Q0 OK \\ dATDT \\ T TIMEOUT 40 CONNECT " 
   set timeout 180 # 3 minute idle timer (the default) 
   enable dns # request DNS info (for resolv.conf) 

  3g: 
      set log Phase Chat LCP IPCP CCP tun command 
      ident user-ppp VERSION 
      set device / dev/cuaU0.0 
      set speed 460 800 
      set phone "* 99 *** 1 #" 
      set dial "ABORT BUSY ABORT NO \ \ sCARRIER TIMEOUT 5 \ 
          \ "\" AT OK-AT-OK ATS0 = 0 OK \ 
          AT & amp; FE0V1X1 & amp; D2 & amp; C1S0 = 0 OK \ 
          AT + CGDCONT = 1, \ \ \ "IP \ \ \", \ \ \ "three.co.uk \ \ \" OK \ 
          \ \ DATDT \ \ T TIMEOUT 10 CONNECT " 
      set login 
      set cd off 
      set authname "three" 
      set authkey "three" 
      disable ipv6cp 
      disable pap 
      disable chap 
      disable dns 
      disable vjcomp 
      accept vjcomp 
      set reconnect 30 0 
      set redial 10 0 
      set ifaddr 10.0.0.1 / 0 10.0.0.2 / 0 255.255.255.255 0.0.0.0 
      add!  default HISADDR
```

After running [CMD="ppp -ddial 3g"][/CMD], it adds the interface tun0 but the inet address stays as 0.0.0.0 > 255.255.255.0 and I am still unable to connect. There is no relevant information in /var/log/ppp.conf which states what the problem is.


----------



## SirDice (Dec 22, 2011)

You have a lot of 'extra' spaces in places where there shouldn't be any.

For example:

```
set speed 115 200
```
Should be:

```
set speed 115200
```


```
AT + CDGCONT
```
Should be 

```
AT+CDGCONT
```

Etc.. There are a lot more that need to be changed.


----------



## Amzo (Dec 22, 2011)

Might be it. I took the base config from a Russian site. Google translator must've messed up the formatting. I'll Give it a try removing the spaces.


```
default: 
   set log Phase Chat LCP IPCP CCP tun command 

   set device /dev/cuaU0.2 # I have so maybe you will have 0 

   set speed 115200 
   set dial "ABORT BUSY ABORT NO \\ sCARRIER TIMEOUT 5 \"\" AT OK-AT-OK ATE1Q0 OK \\ dATDT \\T TIMEOUT 40 CONNECT " 
   set timeout 180 # 3 minute idle timer (the default) 
   enable dns # request DNS info (for resolv.conf) 

  3g: 
      set log Phase Chat LCP IPCP CCP tun command 
      ident user-ppp VERSION 
      set device /dev/cuaU0.2
      set speed 460800 
      set phone "*99#" 
      set dial "ABORT BUSY ABORT NO \\sCARRIER TIMEOUT 5 \\"\" AT OK-AT-OK ATS0 = 0 OK\ AT & FE0V1X1 ; D2 & C1S0 = 0 OK \ +CGDCONT = 1, \\\ "IP \\\", \\\ "three.co.uk\\\" OK \\\DATDT \\T TIMEOUT 10 CONNECT " 
      set login 
      set cd off 
      set authname "three" 
      set authkey "three" 
      disable ipv6cp 
      disable pap 
      disable chap 
      disable dns 
      disable vjcomp 
      accept vjcomp 
      set reconnect 30 0 
      set redial 10 0 
      set ifaddr 10.0.0.1 / 0 10.0.0.2 / 0 255.255.255.255 0.0.0.0 
      add default HISADDR
```

The only part I'm not sure about which may be incorrect is the set dial line.


----------



## SirDice (Dec 22, 2011)

Compare with the examples in the handbook: 28.2 Using User PPP

A 3G or UMTS connection is basically used the same way as an old-fashioned telephone dial-in. The only real difference is the phonenumber.


----------



## Amzo (Dec 22, 2011)

I have read through that and rewrote my config. So far I get the interface tun0 with a inet of 10.0.0.1/0 > 10.0.0.2/0 and it writes an ip to /etc/resolv.conf but I am still unable to connect. I can only get this far when I use:

[CMD="ppp"]-auto[/CMD]

My current ppp config is as follows:


```
default:
 set log Phase Chat LCP IPCP CCP tun command
 ident user-ppp VERSION
 set device /dev/cuaU0.2
 set speed 115200
 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \"\" AT OK-AT-OK ATE1Q0 OK AT+CGDCONT=1,\\\"IP\\\",\\\"three.co.uk\\\" OK \\dATDT\\T TIMEOUT 40 CONNECT"
 set timeout 180			
 enable dns				
 set phone "*99#" 
 set authname "three" 
 set authkey "three" 
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 
 add default HISADDR
```


----------



## Amzo (Dec 22, 2011)

Here is the current output of /var/log/ppp.log


```
Dec 22 22:22:03 Bahamut ppp[1611]: Phase: Using interface: tun1
Dec 22 22:22:03 Bahamut ppp[1611]: Phase: deflink: Created in closed state
Dec 22 22:22:03 Bahamut ppp[1611]: tun1: Command: default: set device /dev/cuaU0.2
Dec 22 22:22:03 Bahamut ppp[1611]: tun1: Command: default: set speed 115200
Dec 22 22:22:03 Bahamut ppp[1611]: tun1: Command: default: set dial ABORT BUSY ABORT NO\sCARRIER TIMEOUT 5 "" AT  OK-AT-OK
 AT+CGDCONT=1,\"IP\",\"three.co.uk\"OK ATD*99#CONNECT
Dec 22 22:22:03 Bahamut ppp[1611]: tun1: Phase: PPP Started (interactive mode).
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Command: /dev/ttyv0: dial
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Phase: bundle: Establish
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Phase: deflink: closed -> opening
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Phase: deflink: Connected!
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Phase: deflink: opening -> dial
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: deflink: Dial attempt 1 of 1
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Send: AT^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Expect(5): OK
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: 
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: 
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: 
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^BOOT:37438007,0,0,0,87^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^BOOT:37438007,0,0,0,87^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:05 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Expect timeout
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Send: AT^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Expect(5): OK
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Received: AT^M^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Received: OK^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Send: AT+CGDCONT=1,"IP","three.co.uk"OK^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Expect(5): ATD*99#CONNECT
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Received: AT+CGDCONT=1,"IP","three.co.uk"OK^M^M
Dec 22 22:22:10 Bahamut ppp[1611]: tun1: Chat: Received: OK^M
Dec 22 22:22:11 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:11 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:14 Bahamut ppp[1611]: tun1: Chat: Received: ^M
Dec 22 22:22:14 Bahamut ppp[1611]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Chat: Expect timeout
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Warning: Chat script failed
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: deflink: dial -> hangup
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: deflink: Disconnected!
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: deflink: Connect time: 10 secs: 0 octets in, 0 octets out
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: deflink: 0 packets in, 0 packets out
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase:  total 0 bytes/sec, peak 0 bytes/sec on Thu Dec 22 22:22:05 2011
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: deflink: hangup -> closed
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Phase: bundle: Dead
Dec 22 22:22:26 Bahamut ppp[1611]: tun1: Command: /dev/ttyv0: quit
Dec 22 22:22:26 Bahamut ppp[1611]: tun1: Phase: PPP Terminated (normal).
Dec 22 22:23:00 Bahamut ppp[1628]: Phase: Using interface: tun1
Dec 22 22:23:00 Bahamut ppp[1628]: Phase: deflink: Created in closed state
Dec 22 22:23:00 Bahamut ppp[1628]: tun1: Command: default: set device /dev/cuaU0.2
Dec 22 22:23:00 Bahamut ppp[1628]: tun1: Command: default: set speed 115200
Dec 22 22:23:00 Bahamut ppp[1628]: tun1: Command: default: set dial ABORT BUSY ABORT NO\sCARRIER TIMEOUT 5 "" AT  OK-AT-OK
 AT+CGDCONT=1,\"IP\",\"three.co.uk\"  ATD*99#
Dec 22 22:23:00 Bahamut ppp[1628]: tun1: Phase: PPP Started (interactive mode).
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Command: /dev/ttyv0: dial
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Phase: bundle: Establish
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Phase: deflink: closed -> opening
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Phase: deflink: Connected!
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Phase: deflink: opening -> dial
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: deflink: Dial attempt 1 of 1
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Send: AT^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Expect(5): OK
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: 
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: 
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: 
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^BOOT:37438007,0,0,0,87^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:01 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:02 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:02 Bahamut ppp[1628]: tun1: Chat: Received: ^RSSI:19^M
Dec 22 22:23:04 Bahamut ppp[1628]: tun1: Chat: Received: ^M
Dec 22 22:23:04 Bahamut ppp[1628]: tun1: Chat: Received: ^BOOT:37438007,0,0,0,87^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Expect timeout
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Send: AT^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Expect(5): OK
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Received: AT^M^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Received: OK^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Send: AT+CGDCONT=1,"IP","three.co.uk"^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Expect(5): ATD*99#
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Received: AT+CGDCONT=1,"IP","three.co.uk"^M^M
Dec 22 22:23:06 Bahamut ppp[1628]: tun1: Chat: Received: OK^M
```


----------



## fbsd1 (Dec 23, 2011)

You have incrrect statement

```
set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0
```

The install guide has detailed description on  user ppp http://www.a1poweruser.com


```
# Get dynamic IP address from ISP if that's how they do it.
 set ifaddr 0.0.0.0/0 0.0.0.0/0 0.0.0.0 0.0.0.0

# Use static IP address from ISP if that's how they do it.
# Set static IP address your ISP assigned to you.
# s.s.s.s = your static IP address

# set ifaddr s.s.s.s 0.0.0.0/0 0.0.0.0 0.0.0.0

 add default HISADDR    # Add Mandatory sticky default route
                        # Gets the ISP's DNS IP address
                        # places them in resolv.conf for
                        # reference by FBSD.

 disable iface-alias    # Stop adding old IP address as alias
                        # when ppp redials because line was
                        # lost. These old IPs showed using
                        # ifconfig -a on tun0.

iface clear             # Remove all previous IP addresses
```


----------



## SirDice (Dec 23, 2011)

fbsd1 said:
			
		

> You have incrrect statement
> 
> ```
> set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0
> ```


No, it is partly correct. It needs to be set to an IP address. Which addresses you use is not relevant. But it should look like this:

```
set ifaddr 10.0.0.1/0 10.0.0.2/0 0.0.0.0 0.0.0.0
```


```
5.   Use the ``set ifaddr'' command to define the IP address.

          o   If you know what IP address your provider uses, then use it as
              the remote address (dst_addr), otherwise choose something like
              10.0.0.2/0 (see below).

          o   If your provider has assigned a particular IP address to you,
              then use it as your address (src_addr).

          o   If your provider assigns your address dynamically, choose a
              suitably unobtrusive and unspecific IP number as your address.
              10.0.0.1/0 would be appropriate.  The bit after the / specifies
              how many bits of the address you consider to be important, so if
              you wanted to insist on something in the class C network
              1.2.3.0, you could specify 1.2.3.1/24.

          o   If you find that your ISP accepts the first IP number that you
              suggest, specify third and forth arguments of ``0.0.0.0''.  This
              will force your ISP to assign a number.  (The third argument
              will be ignored as it is less restrictive than the default mask
              for your `src_addr').

          An example for a connection where you do not know your IP number or
          your ISPs IP number would be:

                set ifaddr 10.0.0.1/0 10.0.0.2/0 0.0.0.0 0.0.0.0
```
Taken from ppp(8).


----------



## Amzo (Dec 23, 2011)

Well after correcting that I still have this line in my log:


```
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Chat: Expect timeout
Dec 22 22:22:15 Bahamut ppp[1611]: tun1: Warning: Chat script failed
```

Even tho, in my main chat script I specified a timeout:


```
set dial "ABORT BUSY TIMEOUT 5\\sCARRIER TIMEOUT 30 \"\" AT \ OK-AT-OK \AT+CGDCONT=1,\\\"IP\\\",\\\"three.co.uk\\\" \ ATD*99# \\t TIMEOUT 45 CONNECT"
```


----------



## Va551L (Jun 11, 2012)

I found this configuration file on a russian site. It works for me out of the box with Huawei E173 after changing the name of ISP "mtel" in my case:


```
default:
 set log Phase Chat LCP IPCP CCP tun command
 ident user-ppp VERSION
mtel3g:
 set device /dev/ttyU0.0
 set speed 460800
 set dial "\"\" \
 AT OK \
 AT OK \
 ATS0=0 OK \
 AT OK \
 AT&FE0V1X1&D2&C1s0=0 OK \
 AT OK \
 AT+CGDCONT=1,\\\"IP\\\",\\\"internet\\\" OK \
 ATDT*99***1# CONNECT"
 set login
 set authname "mtel"
 set authkey "mtel"
 disable ipv6cp
 disable pap
 disable chap
 enable dns
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
 add default HISADDR
```


----------

