Turn any computer into a 3G router in fixnum minutes
Updated 2026-06-17
Quick and dirty howto. I'll use a Huawei E174 3G USB modem with a working sim hard, and a Zyxel G-220 USB wi-fi adapter.
First, install ppp and configure the the 3G modem by writing a chat script and setting ppp options in /etc/ppp/peers/provider:
connect "/usr/sbin/chat -v \
TIMEOUT 35 \
ECHO ON \
ABORT '\nBUSY\r' \
ABORT '\nERROR\r' \
ABORT '\nNO ANSWER\r' \
ABORT '\nNO CARRIER\r' \
ABORT '\nNO DIALTONE\r' \
ABORT '\nRINGING\r\n\r\nRINGING\r' \
ABORT '\nUsername/Password Incorrect\r' \
'' \rAT \
OK 'AT+CGDCONT=1,\"IP\",\"web.be\"' \
OK 'ATD*99#' \
CONNECT '\d\c'"
/dev/ttyUSB0
115200
crtscts
noauth
usepeerdns
#noipdefault
persist
debug
defaultroute
user "web"
password web
Then, install hostapd and configure the wi-fi card in master mode in /etc/hostapd.conf:
interface=wlan1
bridge=br0
driver=nl80211
ssid=MyNetwork
hw_mode=g
channel=1
start the card in master mode, assign an IP address to it
hostapd /etc/hostapd.conf
ifconfig wlan1 192.168.0.1
Then install and configure the DHCP server in /etc/dhcp/dhcpd.conf by adding the following lease configuration:
subnet 192.168.0.0 netmask 255.255.255.224 {
range 192.168.0.10 192.168.0.20;
option routers 192.168.0.1;
option domain-name-servers 8.8.4.4;
}
start the ppp daemon using pon provider this also sets dns and the default gateway properly.