OCG Scripts
The ocg-scripts recipe provides a small set of simple scripts that are useful for demos, testing, and as examples for developers. They are not intended to be full-featured scripts that cover a wide-range of use cases.
ocg-cell-router
Configures the OCG as a basic network router/firewall. All incoming connections on the WAN are blocked by default and all outbound traffic from the LAN is allowed. Enables IP forwarding and masquerading/NAT.
Usage: ocg-cell-router start|stop [options] options: -lLAN interfaces to allow, comma-separated (defaults to "eth0") -w WAN interface to route out (defaults to "ppp0")
ocg-set-apn
Helper script to set the APN in the /etc/ppp/peers/gsm_chat
file, rather than having to edit it by hand.
Usage: ocg-set-apn APN
ocg-dhcpd
Simple script to stop and start the busybox udhcpd server. To edit dhcpd config, edit /etc/udhcpd.conf
. The default configuration works with the default IP address of 192.168.2.1 and subnet mask of 255.255.255.0.
Usage: ocg-dhcpd start|stop|restart
ocg-wifi-ap
Enables a Wi-Fi AP on the OCG. Tested with MT100EOCG + MTPCIE-H5-BW with integrated Bluetooth/Wifi (other hardware configurations don’t have Wi-Fi support).
Starts and stops hostapd and dhcpd with some minimal configuration. By default, it enables an access point on 192.168.3.1 so as not to conflict with the default ethernet address of 192.168.2.1. DHCP server will run on Wi-Fi only unless it is bridged with the ethernet interface.
The script will only automatically modify a few settings. Any other changes need to be made to /etc/hostapd.conf
and /etc/udhcpd.conf
manually.
Automatically enables/disables bridge mode in /etc/hostapd.conf
as needed
Configures router address and DHCP address range in /etc/udhcdp.conf to match wlan0 address if “-a” option is used
Usage: ocg-wifi-ap start|stop|restart [options] options: -a Sets AP IP address (defaults to 192.168.3.1) -bAdd AP to specified bridge interface (conflicts with -a)
Examples
Ethernet to Cellular router example
ocg-set-apn APN (one-time only for GSM connections) ocg-cell-router start ocg-dhcpd start pppd call gsm
Wifi AP to Cellular router with Ethernet on separate subnets and DHCP on Wifi only
ocg-set-apn APN (one-time only for GSM connections) ocg-cell-router start -l eth0,wlan0 ocg-wifi-ap start pppd call gsm
Wifi AP and Ethernet bridged Cellular router
Edit /etc/network/interfaces -- enable br0 and disable normal eth0 setup reboot ocg-set-apn APN (one-time only for GSM connections) ocg-cell-router start -l br0 ocg-wifi-ap start -b br0 pppd call gsm