# Adjustable routing



## balanga (Oct 15, 2018)

How do I go about changing my routing if I connect up to the Internet using an LTE/4G modem whilst connected to my home
 LAN which has its own Internet Gateway?

The use of the modem only occurs from time to time.

Is there any way I can get the routing changed when I insert or eject the modem?


----------



## aragats (Oct 16, 2018)

Assuming you have a USB modem. Create a file e.g. /etc/devd/modem.conf:
	
	



```
attach 100 {
        match "vendor"          "0xXXXX";
        match "product"         "0xYYYY";
        action "/home/balanga/bin/modem_attach.sh";
};
detach 100 {
        match "vendor"          "0xXXXX";
        match "product"         "0xYYYY";
        action "/home/balanga/bin/modem_detach.sh";
};
```
Then you can write those scripts modem_attach.sh and modem_detach.sh to do the job.
Something like:
	
	



```
route del X.X.X.X/A Y.Y.Y.Y
route add Z.Z.Z.Z/B W.W.W.W
```


----------



## ondra_knezour (Oct 16, 2018)

You can also use a ppp command/script/config, if ppp is involved, see ppp(8), search for add! default HISADDR


----------



## balanga (Oct 16, 2018)

ondra_knezour said:


> You can also use a ppp command/script/config, if ppp is involved, see ppp(8), search for add! default HISADDR




I could never get my head around ppp scripts/configs and have fortunately managed to connect to the Internet using RNDIS which is far simply (once it's set up).


----------



## balanga (Oct 16, 2018)

aragats said:


> Assuming you have a USB modem. Create a file e.g. /etc/devd/modem.conf:
> 
> 
> 
> ...



Thanks for the help with routing... I'm issuing the followings commands:-


```
net del default
net add default 192.168.3.1
```

This gives me access to the Internet via my LTE modem. Just need figure out how to get the scripts to work.


----------



## SirDice (Oct 16, 2018)

It's `route add ...`, not `net add ...`, see route(8).


----------



## balanga (Oct 16, 2018)

Typo....


----------

