# iOS tethering & default route



## dch (Jun 13, 2016)

My iphone 6s+ (the continent-sized one) is recognised in 11.0-CURRENT now:


```
ipheth0: <Apple Inc. iPhone, class 0/0, rev 2.00/8.02, addr 7> on usbus0
ue0: <USB Ethernet> on ipheth0
ue0: Ethernet address: 82:ed:2c:45:8e:f7
```

I've been doing the following to set up tethering:


```
# pkg install -y usbmuxd libimobiledevice
# usbmuxd -U root -f &
# dhclient ue0
```

Which works, however I still need to (manually) set the default route.

`dhclient ue0` retrieves the following settings from the tethered phone, including the correct route:


```
lease {
  interface "ue0";
  fixed-address 172.20.10.4;
  next-server 172.20.10.1;
  server-name "dch";
  option subnet-mask 255.255.255.240;
  option routers 172.20.10.1;
  option domain-name-servers 172.20.10.1;
  option dhcp-lease-time 85536;
  option dhcp-message-type 5;
  option dhcp-server-identifier 172.20.10.1;
  renew 6 2016/6/4 19:25:54;
  rebind 0 2016/6/5 04:20:30;
  expire 0 2016/6/5 07:18:42;
}
lease {
  interface "ue0";
  fixed-address 172.20.10.4;
  next-server 172.20.10.1;
  server-name "dch";
  option subnet-mask 255.255.255.240;
  option routers 172.20.10.1;
  option domain-name-servers 172.20.10.1;
  option dhcp-lease-time 85536;
  option dhcp-message-type 5;
  option dhcp-server-identifier 172.20.10.1;
  renew 1 2016/6/13 22:02:49;
  rebind 2 2016/6/14 06:57:25;
  expire 2 2016/6/14 09:55:37;
}
```

1. is there a better manual way than adding a `defaultrouter="172.20.10.1"` info /etc/rc.conf each time and re-running `service routing restart` ?

2. is there a way to get dhclient to set the route for me automatically, and ideally tear down the route when tethering is disconnected?


----------



## kpa (Jun 13, 2016)

2. The system should do that automatically if dhclient(8) is used. Try doing it this way in /etc/rc.conf:


```
ifconfig_ue0="DHCP"
```

You'll need to run `# service netif restart ue0` to get the connection going. Edit: run this in place of the `dhclient` invocation you're now using.


----------



## dch (Jun 13, 2016)

Thanks kpa I rebooted my laptop without any wifi/ethernet bits, and then pulled in tethering. Now dhclient works as expected. I guess the issue is if you already have some network connectivity through an alternate device, then changing the default route (or adding additional / alternate routes) is not something dhclient can handle itself.


----------

