# USB Tethering: How to auto-configure?



## AngryWolf (Aug 12, 2014)

Hi All,

I have an LG G2 phone that can share its mobile internet via USB tethering. FreeBSD 9.3 recognizes it, but does not automatically obtain an IP address via DHCP and set it to the default route when I enable USB tethering on my device. Is there any way to do that? Just like under Windows. (And also revert settings when tethering is disabled.)

Thanks in advance.

*Details:*

Kernel module: if_urndis.ko

`dmesg` output:


```
ugen1.3: <LG Electronics Inc.> at usbus1
umodem0: <CDC Abstract Control Model ACM> on usbus1
umodem0: data interface 1, has no CM over data, has no break
cdce0: <CDC Ethernet Control Model ECM> on usbus1
ue0: <USB Ethernet> on cdce0
ue0: Ethernet address: 3e:51:7b:3f:3c:17
```

`dhclient ue0` output:


```
DHCPREQUEST on ue0 to 255.255.255.255 port 67
DHCPACK from 192.168.42.129
bound to 192.168.42.45 -- renewal in 3600 seconds.
```

`ifconfig` output:


```
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 3e:51:7b:3f:3c:17
	inet 192.168.42.45 netmask 0xffffff00 broadcast 192.168.42.255
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```

`netstat -rn` output:


```
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.0.0.1           UGS         0   164178    re0
10.0.0.0/24        link#3             U           0     1789    re0
10.0.0.7           link#3             UHS         0        0    lo0
127.0.0.1          link#5             UH          0       24    lo0
192.168.42.0/24    link#6             U           0        0    ue0
192.168.42.45      link#6             UHS         0        0    lo0
```

And after issuing the following command I got Internet from my phone:


```
# route change default 192.168.42.129
change net default: gateway 192.168.42.129
```


----------



## SirDice (Aug 12, 2014)

AngryWolf said:
			
		

> I have an LG G2 phone that can share its mobile internet via USB tethering. FreeBSD 9.3 recognizes it, but does not automatically obtain an IP address via DHCP and set it to the default route when I enable USB tethering on my device. Is there any way to do that?


You may be able to fire off a script using devd.conf(5) when the device is detected. The script could do that automatically.


----------



## mod3777 (Mar 25, 2019)

Use SYNCDHCP instead of DHCP. That will automatically assign an IP address


----------

