moxa-v2101-series-linux-manual-v2.0
moxa-v2101-series-linux-manual-v2.0
www.moxa.com/product
The software described in this manual is furnished under a license agreement and may be used only in accordance with
the terms of that agreement.
Copyright Notice
Trademarks
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment on the part of
Moxa.
Moxa provides this document as is, without warranty of any kind, either expressed or implied, including, but not limited
to, its particular purpose. Moxa reserves the right to make improvements and/or changes to this manual, or to the
products and/or the programs described in this manual, at any time.
Information provided in this manual is intended to be accurate and reliable. However, Moxa assumes no responsibility for
its use, or for any infringements on the rights of third parties that may result from its use.
This product might include unintentional technical or typographical errors. Changes are periodically made to the
information herein to correct such errors, and these changes are incorporated into new editions of the publication.
www.moxa.com/support
Moxa Americas Moxa China (Shanghai office)
Toll-free: 1-888-669-2872 Toll-free: 800-820-5036
Tel: +1-714-528-6777 Tel: +86-21-5258-9955
Fax: +1-714-528-6778 Fax: +86-21-5258-5505
Moxa India
Tel: +91-80-4172-9088
Fax: +91-80-4132-1045
Table of Contents
Thank you for purchasing the Moxa V2101 Series of x86 ready-to-run embedded computers. This manual
introduces the software configuration and management of the V2101-LX, which runs the Linux operating
system. For hardware installation, connector interfaces, setup, and upgrading the BIOS, please refer to the
“V2101 Series Hardware User’s Manual.”
Linux is an open, scalable operating system that allows you to build a wide range of innovative, small footprint
devices. Software written for desktop PCs can be easily ported to the embedded computer with a GNU cross
compiler and a minimum of source code modifications. A typical Linux-based device is designed for a specific
use, and is often not connected to other computers, or a number of such devices connect to a centralized,
front-end host. Examples include enterprise tools such as industrial controllers, communications hubs,
point-of-sale terminals, and display devices, which include HMIs, advertisement appliances, and interactive
panels.
Overview
Software Specifications
Software Components
V2101 Series Linux Introduction
Overview
V2101 embedded computers are based on the Intel Atom Menlow XL x86 processor and feature two serial ports,
dual Gigabit LAN ports, four USB 2.0 hosts, and an SD socket. The V2100 series offers both VGA and LVDS
outputs, making it exceptionally well suited for industrial applications such as SCADA and factory automation.
The V2101’s two serial ports make it ideal for connecting a wide range of serial devices, and the dual
10/100/1000 Mbps Ethernet ports offer a reliable solution for network redundancy, which taken together
promise continuous data communication and management operations. For added convenience, the V2101 has
three DIs and three DOs for connecting digital input/output devices. In addition, the SD and USB ports provide
V2101 computers with data buffering and storage expansion, which provide the necessary reliability for
industrial applications.
Pre-installed with Linux, the V2101 Series provides programmers with a friendly environment for developing
sophisticated, bug-free application software at a lower cost.
All V2101 models support a wide operating temperature range of -40 to 85°C for use in harsh industrial
environments.
Software Specifications
The Linux operating system pre-installed on the V2101 embedded computer is the Debian Lenny 5.0
distribution. The Debian project is a worldwide group of volunteers who endeavor to produce an operating
system distribution that composed entirely of free software. The Debian GNU/Linux follows the standard Linux
architecture, making it easy to use programs that meet the POSIX standard. Program porting can be done with
the GNU Tool Chain provided by Moxa. In addition to Standard POSIX APIs, device drivers for Moxa UART and
other special peripherals are also included. An example software architecture is shown below:
ATTENTION
Refer to http://www.debian.org/ and http://www.gnu.org/ for information and documentation of the Debian
GNU/Linux and free software concept.
1-2
V2101 Series Linux Introduction
ATTENTION
The above software architecture is only an example. Different models or different build revisions of the Linux
operating system may include components not shown in the above graphic.
Software Components
The Debian 5.0/Lenny Linux system installed on this computer includes the following software components:
acpi-support-base 0.109-11 scripts for handling base ACPI events such as the
power button
acpid 1.0.8-1lenny1 Utilities for using ACPI power management
adduser 3.110 add and remove users and groups
alacarte 0.11.5-1 easy GNOME menu editing tool
alsa-base 1.0.17.dfsg-4 ALSA driver configuration files
alsa-utils 1.0.16-2 ALSA utilities
apache2 2.2.9-10+lenny6 Apache HTTP Server metapackage
apache2-doc 2.2.9-10+lenny2 Apache HTTP Server documentation
apache2-mpm-prefork 2.2.9-10+lenny6 Apache HTTP Server - traditional non-threaded
model
apache2-utils 2.2.9-10+lenny4 utility programs for webservers
apache2.2-common 2.2.9-10+lenny6 Apache HTTP Server common files
app-install-data 2008.11.27 Application Installer Data Files
apt 0.7.20.2+lenny1 Advanced front-end for dpkg
apt-file 2.1.5 APT package searching utility -- command-line
interface
apt-utils 0.7.20.2+lenny1 APT utility programs
aptitude 0.4.11.11-1~lenny terminal-based package manager
1
arj 3.10.22-6 archiver for .arj files
aspell 0.60.6-1 GNU Aspell spell-checker
aspell-en 6.0-0-5.1 English dictionary for GNU Aspell
audacity 1.3.5-2+lenny1 A fast, cross-platform audio editor
autoconf 2.61-8 automatic configure script builder
autoconf2.13 2.13-59 automatic configure script builder (obsolete
version)
automake 1:1.10.1-3 A tool for generating GNU Standards-compliant
Makefiles
automake1.4 1:1.4-p6-13 A tool for generating GNU Standards-compliant
Makefiles
autotools-dev 20080123.1 Update infrastructure for config.{guess,sub} files
base-files 5lenny4 Debian base system miscellaneous files
base-passwd 3.5.20 Debian base system master password and group
files
bash 3.2-4 The GNU Bourne Again SHell
binutils 2.18.1~cvs200801 The GNU assembler, linker and binary utilities
03-7
bridge-utils 1.4-5 Utilities for configuring the Linux Ethernet bridge
bsdmainutils 6.1.10 collection of more utilities from FreeBSD
bsdutils 1:2.13.1.1-1 Basic utilities from 4.4BSD-Lite
busybox 1:1.10.2-2 Tiny utilities for small and embedded systems
bzip2 1.0.5-1 high-quality block-sorting file compressor - utilities
1-3
V2101 Series Linux Introduction
1-4
V2101 Series Linux Introduction
1-5
V2101 Series Linux Introduction
components)
grub 0.97-47lenny2 GRand Unified Bootloader (Legacy version)
grub-common 1.96+20080724-1 GRand Unified Bootloader, version 2 (common
6 files)
gstreamer0.10-alsa 0.10.19-2 GStreamer plugin for ALSA
gstreamer0.10-plugins-base 0.10.19-2 GStreamer plugins from the "base" set
gstreamer0.10-plugins-good 0.10.8-4.1~lenny2 GStreamer plugins from the "good" set
gstreamer0.10-x 0.10.19-2 GStreamer plugins for X11 and Pango
gtk2-engines 1:2.14.3-2 theme engines for GTK+ 2.x
gzip 1.3.12-6 The GNU compression utility
hal 0.5.11-8 Hardware Abstraction Layer
hal-info 20080508+git200 Hardware Abstraction Layer - fdi files
80601-1
hicolor-icon-theme 0.10-1 default fallback theme for FreeDesktop.org icon
themes
hostname 2.95 utility to set/show the host name or domain name
iceweasel 3.0.6-3 lightweight web browser based on Mozilla
iegd-debian502 10.2.0 Moxa V2100 IEGD package
ifenslave 2 Attach and detach slave interfaces to a bonding
device
ifenslave-2.6 1.1.0-10 Attach and detach slave interfaces to a bonding
device
ifupdown 0.6.8+nmu1 high level tools to configure network interfaces
info 4.11.dfsg.1-4 Standalone GNU Info documentation browser
initramfs-tools 0.92o tools for generating an initramfs
initscripts 2.86.ds1-61 Scripts for initializing and shutting down the
system
installation-report 2.38 system installation report
iproute 20080725-2 networking and traffic control tools
iptables 1.4.2-6 administration tools for packet filtering and NAT
iputils-ping 3:20071127-1 Tools to test the reachability of network hosts
klibc-utils 1.5.12-2 small utilities built with klibc for early boot
laptop-detect 0.13.6 attempt to detect a laptop
leafpad 0.8.13-1 GTK+ based simple text editor
libaa1 1.4p5-37+b1 ascii art library
libacl1 2.2.47-2 Access control list shared library
libao2 0.8.8-4 Cross Platform Audio Output Library
libapache2-mod-php5 5.2.6.dfsg.1-1+len server-side, HTML-embedded scripting language
ny4 (Apache 2 module)
libapm1 3.2.2-12 Library for interacting with APM driver in kernel
libapr1 1.2.12-5+lenny1 The Apache Portable Runtime Library
libaprutil1 1.2.12+dfsg-8+len The Apache Portable Runtime Utility Library
ny4
libapt-pkg-perl 0.1.22+b1 Perl interface to libapt-pkg
libart-2.0-2 2.3.20-2 Library of functions for 2D graphics - runtime files
libasound2 1.0.16-2 ALSA library
libaspell15 0.60.6-1 GNU Aspell spell-checker runtime library
libatk1.0-0 1.22.0-1 The ATK accessibility toolkit
libatk1.0-data 1.22.0-1 Common files for the ATK accessibility toolkit
libattr1 1:2.4.43-2 Extended attribute shared library
libaudiofile0 0.2.6-7 Open-source version of SGI's audiofile library
libavahi-client3 0.6.23-3lenny1 Avahi client library
libavahi-common-data 0.6.23-3lenny1 Avahi common data files
1-6
V2101 Series Linux Introduction
1-7
V2101 Series Linux Introduction
(runtime lib)
libebook1.2-9 2.22.3-1.1+lenny2 Client library for evolution address books
libecal1.2-7 2.22.3-1.1+lenny2 Client library for evolution calendars
libedata-book1.2-2 2.22.3-1.1+lenny2 Backend library for evolution address books
libedata-cal1.2-6 2.22.3-1.1+lenny2 Backend library for evolution calendars
libedataserver1.2-9 2.22.3-1.1+lenny2 Utility library for evolution data servers
libedataserverui1.2-8 2.22.3-1.1+lenny2 GUI utility library for evolution data servers
libedit2 2.11~20080614-1 BSD editline and history libraries
libeel2-2.20 2.20.0-7 Eazel Extensions Library (for GNOME2)
libeel2-data 2.20.0-7 Eazel Extensions Library - data files (for GNOME2)
libegroupwise1.2-13 2.22.3-1.1+lenny2 Client library for accessing groupwise POA through
SOAP, interf
libenchant1c2a 1.4.2-3.3 a wrapper library for various spell checker engines
libept0 0.5.22 High-level library for managing Debian package
information
libesd0 0.2.36-3 Enlightened Sound Daemon - Shared libraries
libevent1 1.3e-3 An asynchronous event notification library
libexempi3 2.0.1-1 library to parse XMP metadata (Library)
libexif12 0.6.16-2.1 library to parse EXIF files
libexpat1 2.0.1-4 XML parsing C library - runtime library
libfam0 2.7.0-13.3 Client library to control the FAM daemon
libffi5 3.0.7-1 Foreign Function Interface library runtime
libflac++6 1.2.1-1.2 Free Lossless Audio Codec - C++ runtime library
libflac8 1.2.1-1.2 Free Lossless Audio Codec - runtime C library
libfont-afm-perl 1.20-1 Font::AFM - Interface to Adobe Font Metrics files
libfontconfig1 2.6.0-3 generic font configuration library - runtime
libfontenc1 1:1.0.4-3 X11 font encoding library
libfreebob0 1.0.7-1 FreeBoB API
libfreetype6 2.3.7-2+lenny1 FreeType 2 font engine, shared library files
libfreezethaw-perl 0.43-4 converting Perl structures to strings and back
libfs6 2:1.0.1-1 X11 Font Services library
libgail-common 1.22.3-1 GNOME Accessibility Implementation Library --
modules common
libgail18 1.22.3-1 GNOME Accessibility Implementation Library --
shared library
libgamin0 0.1.9-2 Client library for the gamin file and directory
monitoring sys
libgcc1 1:4.3.2-1.1 GCC support library
libgconf2-4 2.22.0-1 GNOME configuration database system (shared
libraries)
libgcrypt11 1.4.1-1 LGPL Crypto library - runtime library
libgdata-google1.2-1 2.22.3-1.1+lenny2 Client library for accessing Google POA through
SOAP interface
libgdata1.2-1 2.22.3-1.1+lenny2 Client library for accessing Google POA through
SOAP interface
libgdbm3 1.8.3-3 GNU dbm database routines (runtime version)
libgksu2-0 2.0.7-1 library providing su and sudo functionality
libgl1-mesa-dri 7.0.3-7 A free implementation of the OpenGL API -- DRI
modules
libgl1-mesa-glx 7.0.3-7 A free implementation of the OpenGL API -- GLX
runtime
libglade2-0 1:2.6.2-1 library to load .glade files at runtime
libglib-perl 1:1.190-2 Perl interface to the GLib and GObject libraries
1-8
V2101 Series Linux Introduction
1-9
V2101 Series Linux Introduction
1-10
V2101 Series Linux Introduction
1-11
V2101 Series Linux Introduction
libraw1394-8 1.3.0-4 library for direct access to IEEE 1394 bus (aka
FireWire)
libreadline5 5.2-3.1 GNU readline and history libraries, run-time
libraries
librpcsecgss3 0.18-1 allows secure rpc communication using the
rpcsec_gss protocol
librpm4.4 4.4.2.3-1 RPM shared library
librsvg2-2 2.22.2-2lenny1 SAX-based renderer library for SVG files (runtime)
librsvg2-common 2.22.2-2lenny1 SAX-based renderer library for SVG files (extra
runtime)
libsasl2-2 2.1.22.dfsg1-23+l Cyrus SASL - authentication abstraction library
enny1
libscrollkeeper0 0.3.14-16 Library to load .omf files (runtime files)
libselinux1 2.0.65-5 SELinux shared libraries
libsensors3 1:2.10.7-1 library to read temperature/voltage/fan sensors
libsepol1 2.0.30-2 Security Enhanced Linux policy library for changing
policy bin
libsexy2 0.1.11-2+b1 collection of additional GTK+ widgets - library
libshout3 2.2.2-5 MP3/Ogg Vorbis broadcast streaming library
libsigc++-2.0-0c2a 2.0.18-2 type-safe Signal Framework for C++ - runtime
libslab0 0.9.8.svn.2007043 beautification app libraryfile
0-1.1
libslang2 2.1.3-3 The S-Lang programming library - runtime version
libsm6 2:1.0.3-2 X11 Session Management library
libsmbclient 2:3.2.5-4lenny6 shared library that allows applications to talk to
SMB/CIFS se
libsmbios-bin 2.0.3.dfsg-1 Provide access to (SM)BIOS information -- utility
binaries
libsmbios2 2.0.3.dfsg-1 Provide access to (SM)BIOS information --
dynamic library
libsndfile1 1.0.17-4+lenny2 Library for reading/writing audio files
libsnmp-base 5.4.1~dfsg-12 SNMP (Simple Network Management Protocol)
MIBs and documentation
libsnmp15 .4.1~dfsg-12 SNMP (Simple Network Management Protocol)
library
libsoundtouch1c2 .3.1-2 sound stretching library
libsoup2.4-1 2.4.1-2 an HTTP library implementation in C -- Shared
library
libspeex1 1.2~rc1-1 The Speex codec runtime library
libsplashy1 0.3.13-3 Library to draw splash screen on boot, shutdown,
resume or sus
libsqlite3-0 3.5.9-6 SQLite 3 shared library
libss2 1.41.3-1 command-line interface parsing library
libssl0.9.8 0.9.8g-15+lenny5 SSL shared libraries
libstartup-notification0 0.9-1 library for program launch feedback (shared
library)
libstdc++6 4.3.2-1.1 The GNU Standard C++ Library v3
libstdc++6-4.3-dev 4.3.2-1.1 The GNU Standard C++ Library v3 (development
files)
libsvga1 1:1.4.3-27 console SVGA display libraries
libsysfs2 2.1.0-5 interface library to sysfs
libtag1c2a 1.5-3 TagLib Audio Meta-Data Library
libtalloc1 1.2.0~git2008061 hierarchical pool based memory allocator
1-12
V2101 Series Linux Introduction
6-1
libtasn1-3 1.4-1 Manage ASN.1 structures (runtime)
libtext-charwidth-perl 0.04-5+b1 get display widths of characters on the terminal
libtext-iconv-perl 1.7-1+b1 converts between character sets in Perl
libtext-wrapi18n-perl 0.06-6 internationalized substitute of Text::Wrap
libthai-data 0.1.9-4 Data files for Thai language support library
libthai0 0.1.9-4 Thai language support library
libtheora0 1.0~beta3-1 The Theora Video Compression Codec
libtie-ixhash-perl 1.21-2 ordered associative arrays for Perl
libtiff4 3.8.2-11.2 Tag Image File Format (TIFF) library
libtimedate-perl 1.1600-9 Time and date functions for Perl
libtotem-plparser10 2.22.3-1 Totem Playlist Parser library - runtime version
libtrackerclient0 0.6.6-2 metadata database, indexer and search tool -
library
libts-0.0-0 1.0-4 touch screen library
liburi-perl 1.35.dfsg.1-1 Manipulates and accesses URI strings
libusb-0.1-4 2:0.1.12-13 userspace USB programming library
libuuid-perl 0.02-3+b1 Perl extension for using UUID interfaces as defined
in e2fspro
libuuid1 1.41.3-1 universally unique id library
libvisual-0.4-0 0.4.0-2.1 Audio visualization framework
libvisual-0.4-plugins 0.4.0.dfsg.1-2 Audio visualization framework plugins
libvoikko1 1.7-2 Finnish spell-checker and hyphenator library
libvolume-id0 0.125-7+lenny3 libvolume_id shared library
libvorbis0a 1.2.0.dfsg-3.1 The Vorbis General Audio Compression Codec
libvorbisenc2 1.2.0.dfsg-3.1 The Vorbis General Audio Compression Codec
libvorbisfile3 1.2.0.dfsg-3.1 The Vorbis General Audio Compression Codec
libvte-common 1:0.16.14-4 Terminal emulator widget for GTK+ 2.0 - common
files
libvte9 1:0.16.14-4 Terminal emulator widget for GTK+ 2.0 - runtime
files
libwavpack1 4.50.1-1 an audio codec (lossy and lossless) - library
libwbclient0 2:3.2.5-4lenny6 client library for interfacing with winbind service
libwnck-common 2.22.3-1 Window Navigator Construction Kit - common files
libwnck22 2.22.3-1 Window Navigator Construction Kit - runtime files
libwrap0 7.6.q-16 Wietse Venema's TCP wrappers library
libwww-perl 5.813-1 WWW client/server library for Perl (aka LWP)
libwxbase2.6-0 2.6.3.2.2-3+lenny wxBase library (runtime) - non-GUI support
1 classes of wxWidget
libwxgtk2.6-0 2.6.3.2.2-3+lenny wxWidgets Cross-platform C++ GUI toolkit (GTK+
1 runtime)
libx11-6 2:1.1.5-2 X11 client-side library
libx11-data 2:1.1.5-2 X11 client-side library
libx86-1 1.1+ds1-2 x86 real-mode library
libxapian15 1.0.7-4 Search engine library
libxau6 1:1.0.3-3 X11 authorisation library
libxaw7 2:1.0.4-2 X11 Athena Widget library
libxcb-render-util0 0.2.1+git1-1 utility libraries for X C Binding -- render-util
libxcb-render0 1.1-1.2 X C Binding, render extension
libxcb-xlib0 1.1-1.2 X C Binding, Xlib/XCB interface library
libxcb1 1.1-1.2 X C Binding
libxcomposite1 1:0.4.0-3 X11 Composite extension library
libxcursor1 1:1.1.9-1 X cursor management library
1-13
V2101 Series Linux Introduction
1-14
V2101 Series Linux Introduction
509-5
lxpanel 0.3.8.1-2 a lightweight desktop panel for X
lxrandr 0.1+svn20080716 simple monitor config tool for LXDE
-3
lxsession-lite 0.3.6-2a lightweight X11 session manager (lite version)
lxterminal 0.1.3-2 desktop independent vte-based terminal emulator
lzma 4.43-14 Compression method of 7z format in 7-Zip
program
m4 1.4.11-1 a macro processing language
make 3.81-5 The GNU version of the "make" utility.
makedev 2.3.1-88 creates device files in /dev
man-db 2.5.2-4 on-line manual pager
manpages 3.05-1 Manual pages about using a GNU/Linux system
mawk 1.3.3-11.1 a pattern scanning and text processing language
menu 2.1.41 generates programs menu for all menu-aware
applications
menu-xdg 0.3 freedesktop.org menu compliant window manager
scripts
metacity 1:2.22.0-2 A lightweight GTK2 based Window Manager
metacity-common 1:2.22.0-2 Shared files of lightweight GTK2 based Window
Manager
mime-support 3.44-1 MIME files 'mime.types' & 'mailcap', and support
programs
minicom 2.3-1 friendly menu driven serial communication
program
miscfiles 1.4.2.dfsg.1-9 Dictionaries and otherinteresting files
mktemp 1.5-9 tool for creating temporary files
modconf 0.3.9 Device Driver Configuration
module-init-tools 3.4-1 tools for managing Linux kernel modules
mount 2.13.1.1-1 Tools for mounting and manipulating filesystems
myspell-en-us 1:2.4.0-3 English_american dictionary for myspell
mysql-common 5.0.51a-24+lenny MySQL database common files
2
nano 2.0.7-4 free Pico clone with some new features
nautilus 2.20.0-7 file manager and graphical shell for GNOME
nautilus-cd-burner 2.20.0-1 CD Burning front-end forNautilus
nautilus-data 2.20.0-7 data files for nautilus
ncurses-base 5.7+20081213-1 basic terminal type definitions
ncurses-bin 5.7+20081213-1 terminal-related programs and man pages
net-tools 1.60-22 The NET-3 networking toolkit
netbase 4.34 Basic TCP/IP networking system
netcat-traditional 1.10-38 TCP/IP swiss army knife
nfs-common 1:1.1.2-6lenny1 NFS support files common to client and server
notification-daemon 0.3.7-1+b1 a daemon that displays passive pop-up
notifications
ntp 1:4.2.4p4+dfsg-8l Network Time Protocol daemon and utility
enny2 programs
ntpdate 1:4.2.4p4+dfsg-8l client for setting system time from NTP servers
enny2
obconf 2.0.3-3 Preferences manager for Openbox window
manager
openbox 3.4.7.2-3 standards compliant, fast, light-weight, extensible
window man
1-15
V2101 Series Linux Introduction
1-16
V2101 Series Linux Introduction
1-17
V2101 Series Linux Introduction
systems
tcpd 7.6.q-16 Wietse Venema's TCP wrapper utilities
tcpdump 3.9.8-4 A powerful tool for network monitoring and data
acquisition
telnet 0.17-36 The telnet client
telnetd 0.17-36 The telnet server
tftpd 0.17-16 Trivial file transfer protocol server
tightvncserver 1.3.9-4 virtual network computing server software
traceroute 2.0.11-2 Traces the route taken by packets over an
IPv4/IPv6 network
ttf-dejavu 2.25-3 Metapackage to pull in ttf-dejavu-core and
ttf-dejavu-extra
ttf-dejavu-core 2.25-3 Vera font family derivate with additional characters
ttf-dejavu-extra 2.25-3 Vera font family derivate with additional characters
tzdata 2009l-0lenny1 time zone and daylight-saving time data
ucf 3.0016 Update Configuration File: preserve user changes
to config fil
udev 0.125-7+lenny3 /dev/ and hotplug management daemon
unzip 5.52-12 De-archiver for .zip files
update-inetd 4.31 inetd configuration file updater
usbmount 0.0.14.1 automatically mount and unmount USB mass
storage devices
usbutils 0.73-10 Linux USB utilities
uswsusp 0.7-1.2 tools to use userspace software suspend provided
by Linux
util-linux 2.13.1.1-1 Miscellaneous system utilities
vbetool 1.0-3 run real-mode video BIOS code to alter hardware
state
vim 1:7.1.314-3+lenny Vi IMproved - enhanced vi editor
2
vim-common 1:7.1.314-3+lenny Vi IMproved - Common files
2
vim-runtime 1:7.1.314-3+lenny Vi IMproved - Runtime files
2
vim-tiny 1:7.1.314-3+lenny Vi IMproved - enhanced vi editor - compact version
2
vino 2.22.2-1 VNC server for GNOME
watchdog 5.4-10 A software watchdog
wget 1.11.4-2 retrieves files from the web
whiptail 0.52.2-11.3 Displays user-friendly dialog boxes from shell
scripts
wodim 9:1.1.9-1 command line CD/DVD writing tool
x-ttcidfont-conf 31 TrueType and CID fonts configuration for X
x11-apps 7.3+4 X applications
x11-common 1:7.3+20 X Window System (X.Org) infrastructure
x11-session-utils 7.3+1 X session utilities
x11-utils 7.3+2+nmu1 X11 utilities
x11-xfs-utils 7.3+1 X font server utilities
x11-xkb-utils 7.4+1 X11 XKB utilities
x11-xserver-utils 7.3+5 X server utilities
xarchiver 0.4.6-8 GTK+ frontend for most used compression formats
xauth 1:1.0.3-2 X authentication utility
xbase-clients 1:7.3+20 miscellaneous X clients - metapackage
1-18
V2101 Series Linux Introduction
1-19
V2101 Series Linux Introduction
1-20
2
2. Software Configuration
In this chapter, we explain how to operate a V2101-LX computer directly or your desktop. There are three ways
to connect to the V2101-LX computer: through VGA monitor, by using Telnet over the network, or by using an
SSH console from a Windows or Linux machine. This chapter describes basic Linux operating system
configurations. The advanced network management and configuration will be described in the next chapter
“Managing Communications.”
To log in, type the login name and password as requested. The default values are both root.
Login: root
Password: root
Moxa:~#
Before using the Telnet client, you should change the IP address of your development workstation so that the
network ports are on the same subnet as the IP address for the LAN port that you connect to. For example, if
you connect to LAN 1, you could set your PC’s IP address to 192.168.3.126, and the netmask to 255.255.255.0.
If you connect to LAN 2, you can set your PC’s IP address to 192.168.4.126, and the netmask to
255.255.255.0.
Use a cross-over Ethernet cable to connect your development workstation directly to the target computer, or
use a straight-through Ethernet cable to connect the computer to a LAN hub or switch. Next, use a Telnet client
on your development workstation to connect to the target computer. After a connection has been established,
type the login name and password as requested to log on to the computer. The default values are both root.
Login: root
Password: root
2-2
V2101 Series Linux Software Configuration
Windows Users
Click on the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download PuTTY
(free software) to set up an SSH console for the V2101-LX in a Windows environment. The following screen
shows an example of the configuration that is required.
2-3
V2101 Series Linux Software Configuration
Linux Users
From a Linux machine, use the ssh command to access the V2101-LX’s console utility via SSH.
#ssh 192.168.3.127
MM: Month
DD: Date
hhmm: Hour and Minute
YYYY: Year
Use the following command to write the current system time to the RTC.
moxa@Moxa:~# hwclock –w
MOXA:~# date
Wed Dec 16 03:34:46 CST 2009
MOXA:~# hwclock
Wed 16 Dec 2009 03:35:16 AM CST -0.017600 seconds
MOXA:~# date 121616352009
Wed Dec 16 16:35:00 CST 2009
MOXA:~# hwclock –w
MOXA:~# date ; hwclock
Wed Dec 16 16:36:12 CST 2009
Wed 16 Dec 2009 03:38:13 AM CST -0.016751 seconds
MOXA:~#
NTP Client
The V2101-LX has a built-in NTP (Network Time Protocol) client that is used to initialize a time request to a
remote NTP server. Use ntpdate to update the system time.
#ntpdate time.stdtime.gov.tw
#hwclock –w
2-4
V2101 Series Linux Software Configuration
Visit http://www.ntp.org for more information about NTP and NTP server addresses.
ATTENTION
Before using the NTP client utility, check your IP address and network settings (gateway and DNS) to make
sure an Internet connection is available.
#!/bin/sh
ntpdate time.stdtime.gov.tw
moxa@Moxa:~# You can use the time server’s ip address or domain
moxa@Moxa:~# name directly. If you use domain name, you must
moxa@Moxa:~# enable the domain client on the system by updating
moxa@Moxa:~# /etc/resolv.conf file.
hwclock –w
sleep 100
moxa@Moxa:~# Updates every 100 seconds. The min. time is 100 seconds.
moxa@Moxa:~# Change 100 to a larger number to update RTC less often.
Save the shell script using any file name. For example, fixtime.
How to run the shell script automatically when the kernel boots up
Because the root file system is mounted in Read-only mode, we need to re-mount it using writable permission.
Copy the example shell script fixtime to directory /etc/init.d, and then use chmod 755 fixtime to change
the shell script mode.
moxa@Moxa:~# vi /etc/inittab
2-5
V2101 Series Linux Software Configuration
After you finish writing or modifying the code, remember to execute “umount /” to change the root directory
back to Read-only mode.
moxa@Moxa:~# umount /
moxa@Moxa:~# init q
The following daemons are enabled when the V2101-LX boots up for the first time.
2-6
V2101 Series Linux Software Configuration
MOXA:~# ps -ef
PID Uid VmSize Stat Command
1 root 1296 S init
2 root S [keventd]
3 root S [ksoftirqd_CPU0]
4 root S [kswapd]
5 root S [bdflush]
6 root S [kupdated]
7 root S [mtdblockd]
8 root S [khubd]
10 root S [jffs2_gcd_mtd3]
32 root D [ixp425_csr]
38 root 1256 S stdef
47 root 1368 S /usr/sbin/inetd
53 root 4464 S /usr/sbin/httpd
63 nobody 4480 S /usr/sbin/httpd
64 nobody 4480 S /usr/sbin/httpd
65 nobody 4480 S /usr/sbin/httpd
66 nobody 4480 S /usr/sbin/httpd
67 nobody 4480 S /usr/sbin/httpd
92 bin 1460 S /sbin/portmap
105 root 1556 S /usr/sbin/rpc.statd
109 root 4044 S /usr/sbin/snmpd –s –l /dev/null
111 root 2832 S /usr/sbin/snmptrapd -s
140 root 1364 S /sbin/cardmgr
144 root 1756 S /usr/sbin/rpc.nfsd
146 root 1780 S /usr/sbin/rpc.mountd
153 root 2960 S /usr/sbin/sshd
161 root 1272 S /bin/reportip
162 root 3464 S /bin/massupfirm
163 root 1532 S /sbin/getty 115200 ttyS0
164 root 1532 S /sbin/getty 115200 ttyS1
166 root 3464 S /bin/massupfirm
168 root 3464 S /bin/massupfirm
171 root 3652 S /usr/sbin/sshd
172 root 2200 S -bash
174 root 1592 S ps -ef
MOXA:~#
To run a private daemon, you can edit the file rc.local as follows:
1. Because the root file system is mounted in Read-only mode, you need to re-mount it with write permission.
MOXA:~# cd /etc/
3. Type vi rc.local to edit the configuration file with vi editor.
MOXA:/etc/# vi rc.local
4. Next, add the application daemon that you want to run. We use the example program tcps2-release which
you can find in the CD to illustrate, and configure it to run in the background.
# !/bin/sh
moxa@Moxa:~# Add you want to run daemon
/root/tcps2-release &~
5. After you finish writing or modifying the code, remember to execute “umount /” to change the root directory
back to Read-only mode.
2-7
V2101 Series Linux Software Configuration
MOXA:~# umount /
6. You should be able to find the enabled daemon after you reboot the system.
MOXA:~# ps -ef
PID Uid VmSize Stat Command
1 root 1296 S init
2 root S [keventd]
3 root S [ksoftirqd_CPU0]
4 root S [kswapd]
5 root S [bdflush]
6 root S [kupdated]
7 root S [mtdblockd]
8 root S [khubd]
10 root S [jffs2_gcd_mtd3]
32 root D [ixp425_csr]
38 root 1256 S stdef
47 root 1368 S /usr/sbin/inetd
53 root 4464 S /usr/sbin/httpd
63 nobody 4480 S /usr/sbin/httpd
64 nobody 4480 S /usr/sbin/httpd
65 nobody 4480 S /usr/sbin/httpd
66 nobody 4480 S /usr/sbin/httpd
67 nobody 4480 S /usr/sbin/httpd
92 bin 1460 S /sbin/portmap
97 root 1264 S /root/tcps2-release
105 root 1556 S /usr/sbin/rpc.statd
109 root 4044 S /usr/sbin/snmpd –s –l /dev/null
111 root 2832 S /usr/sbin/snmptrapd -s
140 root 1364 S /sbin/cardmgr
144 root 1756 S /usr/sbin/rpc.nfsd
146 root 1780 S /usr/sbin/rpc.mountd
153 root 2960 S /usr/sbin/sshd
161 root 1272 S /bin/reportip
162 root 3464 S /bin/massupfirm
163 root 1532 S /sbin/getty 115200 ttyS0
164 root 1532 S /sbin/getty 115200 ttyS1
166 root 3464 S /bin/massupfirm
168 root 3464 S /bin/massupfirm
171 root 3652 S /usr/sbin/sshd
172 root 2200 S -bash
174 root 1592 S ps -ef
MOXA:~#
#cd /etc/rc2.d
or
2-8
V2101 Series Linux Software Configuration
MOXA:~# cd /etc/rc2.d
MOXA:/etc/rc2.d#
MOXA:/etc/rc2.d# ls
S19nfs-common S25nfs-user-server S99showreadyled
S20snmpd S55ssh
S24pcmcia S99rmnologin
MOXA:/etc/rc2.d#
MOXA:/etc/rc2.d# ln –s /root/tcps2-release S60tcps2
MOXA:/etc/rc2.d# ls
S19nfs-common S25nfs-user-server S99rmnologin
S20snmpd S55ssh S99showreadyled
S24pcmcia S60tcps2
MOXA:/etc/rc2.d#
To remove the daemon, remove the run file from /etc/rc2.d by using the following command:
MOXA:~# rm –f /etc/rc2.d/S60tcps2
After you finish writing or modifying the code, remember to execute “umount /” to change the root directory
back to Read-only mode.
MOXA:~# umount /
Cron wakes up every minute and checks each command to see if it should be run in that minute. When
executing commands, output is mailed to the owner of the crontab (or to the user named in the MAILTO
environment variable in the crontab, if such a user exists).
Modify the file /etc/crontab to set up your scheduled applications. Crontab files have the following format:
2-9
V2101 Series Linux Software Configuration
#!/bin/sh
ntpdate time.stdtime.gov.tw
hwclock –w
exit 0
MOXA:~# mount
/dev/hda1 on / type ext2 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/hdb2 on /home type ext2 (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sda1 on /media/usb0 type vfat
(rw,noexec,nodev,sync,noatime,gid=25,dmask=0007,fmask=0117)
/dev/sdb1 on /media/usb1 type vfat
(rw,noexec,nodev,sync,noatime,gid=25,dmask=0007,fmask=0117)
MOXA:~#
ATTENTION
Remember to type the command # sync before you disconnect the USB storage device. If you do not issue the
command, you may lose data.
ATTENTION
Remember to exit the /media/usb0 or /media/usb1 directory when you disconnect the USB storage
device. If you stay in /media/usb0 or /media/usb1, the automatic un-mount process will fail. If that
happens, type # umount /media/usb0 to un-mount the USB device manually.
2-10
V2101 Series Linux Software Configuration
Note that only clone mode and single mode are supported. Generic LVDS panels come without OSD, so edit
/etc/X11/xorg.conf and select an appropriate configuration ID for your LVDS panel before running
x-window desktop. Refer to the following for configuration parameters.
1. Set the “ConfigId” value for your LVDS panel resolution. (See the following example where value 3 marked
in blue.)
MOXA:~# vi /etc/X11/xorg.conf
moxa@Moxa:~# Primary (First/only) display
Section "Device"
Identifier "Intel_IEGD-0"
Driver "iegd"
VendorName "Intel(R) DEG"
BoardName "Embedded Graphics"
BusID "0:2:0"
Screen 0
Option "PcfVersion" "1792"
Option "ConfigId" "3"
Option "ALL/7/name" "10x6Samsung"
Option "ALL/7/General/PortOrder" "24000"
Option "ALL/7/General/DisplayConfig" "2"
Option "ALL/7/General/DisplayDetect" "1"
Option "ALL/7/Port/2/General/name" "SDVO"
Option "ALL/7/Port/2/General/EdidAvail" "3"
Option "ALL/7/Port/2/General/EdidNotAvail" "1"
Option "ALL/7/Port/2/General/Rotation" "0"
Note that LVDS output does not support the auto-scaling feature. Therefore, be sure to follow all the steps
for proper LDVS panel resolution setup.
2. In the same file, /etc/X11/xorg.conf, change the value to save screen resolution as the default value. In
the following example we use 1024x768 as the default setting. Save the file to exit.
2-11
V2101 Series Linux Software Configuration
MOXA:~# startx
Once the X-window desktop has been launched, use following application menu to change screen
configurations:
2-12
V2101 Series Linux Software Configuration
The V2101 IEGD driver supports three display configuration modes: SDVO (single), LVDS (single),
SDVO(clone)LVDS. You may choose the display interface in this step. Note that the default setting is SDVO
(clone)LVDS. In this mode, the setting of LVDS output will follow the SDVO mode.
If you would like to use X-window as the default console when the system launches, you will need to install the
package gdm. Refer to the following steps.
If you would like to remove the package and return to text console, use the following command.
2-13
V2101 Series Linux Software Configuration
ATTENTION
Due to VGA driver limitations (refer to
http://edc.intel.com/Download.aspx?id=2390&returnurl=/Software/Downloads/IEGD/default.aspx), system
response may slow or the screen may become blank or corrupted on Linux when switching between X-window
and console text mode in single and clone display configurations on US15W. To remedy this, reboot the system
when switching between the console text mode and X-window.
MOXA:~# uname -a
Linux Moxa 2.6.26-2-686 #1 SMP Sun Jul 26 21:25:33 UTC 2009 i686 GNU/Linux
MOXA:~#
MOXA:~# vi /etc/apt/sources.list
#
moxa@Moxa:~# deb cdrom:[Debian GNU/Linux 5.0.2a _Lenny_ - Official i386 NETINST
Binary-1 20
090817-16:43]/ lenny main
#deb cdrom:[Debian GNU/Linux 5.0.2a _Lenny_ - Official i386 NETINST Binary-1 200
90817-16:43]/ lenny main
2-14
V2101 Series Linux Software Configuration
MOXA:~# umount /
MOXA:~#
ATTENTION
The APT cache space /var/cache/apt is located in tmpfs. If you need to install a huge package, link
/var/cache/apt to USB mass storage or mount it to an NFS space to generate more free space. Use df –h to
check how much free space is available on tmpfs.
MOXA:~# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.6G 972M 560M 64% /
udev 10M 700K 9.4M 7% /dev
/dev/hda1 1.6G 972M 560M 64% /
tmpfs 502M 0 502M 0% /lib/init/rw
tmpfs 502M 0 502M 0% /dev/shm
none 502M 19M 483M 4% /tmp
/dev/hda2 199M 125M 63M 67% /home
MOXA:~#
ATTENTION
You can free up the cache space with the command # apt-get clean
2-15
3
3. Managing Communications
The V2101-LX ready-to-run embedded computer is a network-centric platform designed to serve as a front-end
for data acquisition and industrial control applications. This chapter describes how to configure the various
communication functions supported by the Linux operating system.
The rule for setting up network interfaces with a persistent naming order is found here:
/lib/udev/rules.d/75-persistent-net-generator.rules
and it looks like this:
The above example indicates that the system has detected two Ethernet interfaces, and assigned them the
names eth0 (which is associated with the MAC address 00:90:e8:00:de:a8) and eth1 (associated with the
MAC address 00:90:e8:00:de:a9).
ATTENTION
When replacing or connecting a network interface, the system may fail to remove the old record from
/etc/udev/rules.d/70-persistent-net.rules. This could cause network interfaces to be detected
abnormally. To avoid this problem, simply delete the 70-persistent-net.rules file and reboot the system.
ATTENTION
It may also be necessary to configure a persistent naming order for other system peripherals (e.g., storage
drives); to find out more, you may start with the Writing Udev Rules tutorial, found at Ractivated.Net:
http://www.reactivated.net/writing_udev_rules.html
Symantec also offers an effective tutorial, Setting Persistent SCSI Device Names On Linux Using UDEV,
found here:
http://www.symantec.com/business/support/index?page=content&id=TECH71007
To get an idea of what Udev can do for you, check out this Linux For You article from 2012, Some Nifty udev
Rules and Examples:
http://www.linuxforu.com/2012/06/some-nifty-udev-rules-and-examples/
3-2
V2101 Series Linux Managing Communications
The file used for configuring network interfaces is the networking interfaces configuration file, located in
the /etc/network directory. The /etc/network/interfaces file is where you will configure Ethernet LAN
ports for either static or dynamic (DHCP) IP addressing. To edit this file directly, open the network configuration
file with your preferred editor (below, we use VI):
Static IP Address
The default static IP addresses can be modified. Below, we show the default configuration; changing these
values will change the addressing and broadcast parameters used by the associated interface.
After modifying the boot settings of the LAN interface, issue the following command to immediately activate the
new LAN settings:
3-3
V2101 Series Linux Managing Communications
moxa@MOXA:~# pppoeconf
Next, a dialog will appear telling you pppoeconf is locating your “access concentrator.” If your DSL or ADSL
modem is connected to an active LAN interface, pppoeconf will find it.
If there are no available concentrators, pppoeconf will tell you, and exit; if this happens, check to see you’re
your modems are connected properly.
If pppoeconf successfully discovers a concentrator on an available interfaces, it will return this screen:
3-4
V2101 Series Linux Managing Communications
Noauth indicates that the peer does not need to authenticate itself. Nodetach indicates that the connection will
not detach from the controlling terminal. Without this option, if a serial device other than the terminal on the
standard input is specified, pppd will fork to become a background process.
After choosing whether or not to use noauth and nodetach, the pppoeconf will next ask you for your username
and password.
Finally, you will need to choose whether or not your PPPoE provider will supply you with DNS server addresses.
These addresses are necessary for DNS resolution (see below, in the final step of the next section, Setting up
DNS). It is preferable to click Yes, here; however, if your PPPoE provider does not supply these addresses
automatically, click No and remember that you will need to enter the DNS server addresses into
/etc/resolve.conf by hand.
3-5
V2101 Series Linux Managing Communications
# INBOUND connections
# Every regular user can use PPP and has to use passwords from /etc/passwd
* hostname ““ *
“[email protected]” * “password” *
# UserIDs that cannot use PPP at all. Check your /etc/passwd and add any
# other accounts that should not be able to use pppd!
guest hostname “*” -
master hostname “*” -
root hostname “*” -
support hostname “*” -
stats hostname “*” -
# OUTBOUND connections
[email protected] is the username obtained from the ISP to log in to the ISP account.
password is the corresponding password for the account.
4. Edit the file /etc/ppp/options and add plugin rp-pppoe in the indicated place:
# Wait for up n milliseconds after the connect script finishes for a valid
# PPP packet from the peer. At the end of this time, or when a valid PPP
# packet is received from the peer, pppd will commence negotiation by
# sending its first LCP packet. The default value is 1000 (1 second).
# This wait period only applies if the connect or pty option is used.
#connect-delay <n>
# ---<End of File>---
5. If you connecting over LAN1, use the template below to create a file /etc/ppp/options.eth0. LAN2
should be named /etc/ppp/options.eth1. All interfaces follow this convention.
name [email protected]
mtu 1492
mru 1492
defaultroute
noipdefault
~
~
“/etc/ppp/options.eth0” 5 lines, 67 characters
3-6
V2101 Series Linux Managing Communications
Type your username (the one you set in the /etc/ppp/pap-secrets and /etc/ppp/chap-secrets files)
after the name option. You may add other options as needed.
6. Set up DNS: If you are using DNS servers supplied by your ISP, edit the file /etc/resolv.conf by adding
the following lines of code:
nameserver ip_addr_of_first_dns_server
nameserver ip_addr_of_second_dns_server
For example:
nameserver 168.95.1.1
nameserver 139.175.10.20
Now, you should be able to ise the following command to establish a pppoe connection:
If you want to disconnect the connection, you may use the kill command to kill the pppd process.
moxa@Moxa:~# kill -9 pppd
Notes:
1. If the ADSL modem is connected to the LAN1 port, the connection will be named eth0. If the ADSL
modem is connected to LAN2, it should be named eth1, etc.
2. Type moxa@Moxa: ~# ifconfig ppp0 to check if the connection is OK. If the connection is OK, you
should see the IP address of ppp0. You may use the ping command to test the IP address.
Modem/PPP access is almost identical to connecting directly to a network through the V2101-LX Ethernet port.
Since PPP is a peer-to-peer system, the V2101-LX can also use PPP to link two networks (or a local network to
the Internet) to create a Wide Area Network (WAN).
ATTENTION
The following links will give you more information about setting up PPP:
http://tldp.org/HOWTO/PPP-HOWTO/index.html
http://axion.physics.ubc.ca/ppp-linux.html
The following is an AT command used to connect to a PPP server by modem. Use this command for old ppp
servers that prompt for a login name (replace username with the correct name) and password (replace
3-7
V2101 Series Linux Managing Communications
password with the correct password). Note that debug crtscts and defaultroute 192.XXX.XX.XXX are
optional.
moxa@Moxa:~# pppd connect ‘chat -v ““ ATDT5551212 CONNECT ““‘ login: username \
password: password’ /dev/ttyM0 115200 \
debug crtscts modem defaultroute 192.1.1.17
If the PPP server does not prompt for the username and password, the command should be entered as follows
(replace “username” with the correct username and replace “password” with the correct password):
““ Double quotes—don’t wait for a prompt, but instead do ... (note that you must include
a space after the second quotation mark)
Note: Refer to the chat man page, chat.8, for more information about the chat utility.
crtscts Use hardware flow control between the computer and modem (at baudrate of 115200
this is a must).
modem Indicates that this is a modem device; pppd will hang up the phone before and after
making the call.
defaultroute Once the PPP link is established, make it the default route; if you have a PPP link to the
Internet, this is probably what you want.
192.1.1.17 This is a degenerate case of a general option of the form x.x.x.x:y.y.y.y. Here x.x.x.x
is the local IP address and y.y.y.y is the IP address of the remote end of the PPP
connection. If this option is not specified, or if just one side is specified, then x.x.x.x
defaults to the IP address associated with the local machine’s hostname (located in
/etc/hosts), and y.y.y.y is determined by the remote machine.
If a username and password are required, use the following command (note that noipdefault is optional, and
the username and password are both “root”):
moxa@Moxa:~# pppd connect ‘chat –v” “ “ “ ‘ user root password root \
noipdefault /dev/ttyM0 19200 crtscts
3-8
V2101 Series Linux Managing Communications
moxa@Moxa:~# ifconfig
After executing the command, you should be able to see all of the available network interfaces.
ppp0 should be one of the network interfaces. You should recognize the first IP address as the IP address of the
computer, and the P-t-P address is the address of the server. The output should be similar to this:
Now, type:
moxa@Moxa:~# ping XXX.XX.XXX.XXX
where XXX.XX.XXX.XXX is the address of your name server. The output should be similar to the following:
Try typing:
moxa@Moxa:~# netstat -nr
If your output looks similar but does not have the “destination 0.0.0.0” line (which refers to the default route
used for connections), you may have run pppd without the defaultroute option. At this point, you can try
using Telnet, ftp, or finger, bearing in mind that you will have to use numeric IP addresses unless you have
configured /etc/resolv.conf correctly.
3-9
V2101 Series Linux Managing Communications
You should also add the following line to the file /etc/ppp/pap-secrets:
* * ““ *
The first star (*) lets everyone login. The second star (*) lets every host connect. The pair of double quotation
marks (““) indicates that the file /etc/passwd can be used to check the password. The last star (*) is to let
any IP connect.
The following example does not check the username and password:
moxa@Moxa:~# pppd/dev/ttyM0 115200 crtscts modem 192.168.16.1:192.168.16.2
# Speed
115200
3-10
V2101 Series Linux Managing Communications
ATTENTION
If you would like to have auto dial-in service, you can launch the dial-in service in /etc/inittab with the respawn
command:
By default, the serial interface is set to RS-232. You can use the setinterface command to change the serial
port operation mode, as indicated below:
Telnet/FTP/TFTP Server
For security reasons, the V2101-LX only supports SSH and SFTP. The Telenet, FTP, and TFTP are installed, but
have been disabled. Moxa strongly recommends against the use of Telnet or FTP, both of which are considered
deprectated, today. However, if you wish to use one of these services, you may follow the directions below to
enable or disable these services.
3-11
V2101 Series Linux Managing Communications
…
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp
As with any other changes to the inet.d configuration, you must restart the inetd service for the changes to take
effect.
DNS Utilities
Basic DNS utilities are responsible for managing a system’s hostname, DNS resolver, and the name service
switch. The three configuration files associated with these services are /etc/hostname,
/etc/resolv.conf, and /etc/nsswitch.conf.
moxa@MOXA:~# hostname
your-preferred-hostname
3-12
V2101 Series Linux Managing Communications
Five service specifications may be indicated for any source: files, db, nis, nisplus, or compat. For the hosts
database, you may also specify dns; compatibility mode (compat) may only be used with the passwd, group,
and shadow databases. Use of the files source will have the name service switcher search the /etc directory
to find a file that matches the source name (e.g., /etc/hosts, /etc/passwd, /etc/group), and then that file will
be used. By omitting dns or files you may effectively disable dns or the local hosts file for URL resolution.
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference’ and `info’ packages installed, try:
# `info libc “Name Service Switch”‘ for information about this file.
passwd: compat
group: compat
shadow: compat
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
3-13
V2101 Series Linux Managing Communications
ATTENTION
There are many Apache modules that may be of use to administrators in need of customizations to their
webserver, such as speeding up CGI, or building heightened security. Webserver modules and features are
beyond the scope of this manual. If you wish to find a complete list and full documentation for the native
modules, please refer to the Apache webserver documentation, found here:
http://httpd.apache.org/modules/
For a more completely list of available modules that includes third-party modules, you may refer to Wikipedia:
http://en.wikipedia.org/wiki/List_of_Apache_modules
Default Homepage
The Apache web server’s main configuration file is /etc/apache2/sites-enabled/000-default, with
the default homepage located at /var/www/index.html.
Before you modify the homepage, use a browser (such as Microsoft Internet Explore or Mozilla Firefox) from
your PC to test if the Apache web server is working. Type the LAN1 IP address in the browser’s address box to
open the homepage. If the default address hasn’t changed, then when you type http://192.168.3.127/ in
the address bar of your web browser you should see Apache’s default web page.
Setting Up CGI
CGI comes already enabled. The root CGI directory (where you should put CGI scripts) is /usr/lib/cgi-bin.
You may change this to /var/www/cgi-bin, if you so desire.
ATTENTION
If you have more questions about setting up CGI on Apache 2.2, you may refer to this web page:
http://httpd.apache.org/docs/2.2/howto/cgi.html
Disabling CGI
Support for CGI scripting is enabled by default. To disable it, follow the steps below.
moxa@MOXA:~#/etc# vi /etc/apache2/sites-enabled/000-default
#ScriptAlias /cgi-bin/ /usr/lib/w3m/cgi-bin/
#<Directory “/usr/lib/w3m/cgi-bin/”>
# AllowOverride None
# Options ExecCGI -MultiViews +SymLinksIFOwnerMatch
# #Order allow,deny
# Order deny,allow
# Allow from all
#</Directory>
3-14
V2101 Series Linux Managing Communications
ATTENTION
If you have CGI scripts you wish to transfer to the server, make sure you make the files executable. The
command for this is the change mode command, chmod. To make a file read-only but executable, you may
use the numerical combination 555. To make a file read only but available for editing by root, use the
numerical key 755. The syntax is as follows:
MOXA:~#chmod 555 /usr/lib/cgi-bin/[NAME OF YOUR FILE HERE]
1. Connect the USB storage device to a USB port, and check where the device is mounted:
2. Prepare the web pages and then save the entire /var/www directory to the appropriate USB storage device.
Normally, this should be /media/usb0.
3. Now change the Document Root setting. Open the basic Apache config file in an editor:
4. To enable Apache to read your website from the USB device, you must change the DocumentRoot entry in the
Apache configuration file so that it points to the USB storage device. Navigate to the section beginning with
DocumentRoot, and change the directory that immediately follows to /media/usb0/www. For a standard,
unsecured html page, edit /etc/apache2/sites-available/default as below.
DocumentRoot /media/usb0/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
5. If you have CGI scripts, you must now also change the same file so that the CGI entries point to the files on the
USB device. Change your basic Apache configuration file so that it matches the lines shown in red, below:
6. For webpages that will be connecting using the secure sockets layer, you will need to edit the SSL configuration
file. Open the config file using the following command:
7. Make the changes to your config file so that it matches the lines shown in red below:
<VirtualHost *:443>
...
DocumentRoot /media/usb0/www
<Directory />
Options FollowSymLinks
3-15
V2101 Series Linux Managing Communications
AllowOverride None
</Directory>
...
ScriptAlias /cgi-bin/ /media/usb0/www/cgi-bin/
<Directory “/media/usb0/www/cgi-bin/”>
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
...
</VirtualHost>
8. Use the following compound command to restart the Apache web server:
9. Start your browser and connect to the V2101-LX by typing the current LAN1 IP address in the browser’s
address box.
ATTENTION
Visit the Apache website at http://httpd.apache.org/docs/ for more information about setting up Apache
servers.
If you would like to check your website for HTML compliance, click on the following link to download the web
page test suite from the World Wide Web Consortium:
http://www.w3.org/MarkUp/Test/HTML401.zip
3-16
V2101 Series Linux Managing Communications
Netfilter/iptables
Netfilter is an administrative tool for setting up, maintaining, and inspecting the Linux kernel’s packet filtering
rule tables. Netfilter is a stateful firewall, which means that it filters packets by tracking connections, rather
than each and every individual packet. For more information on connection tracking, see the section
Connection Tracking, in this same chapter, below.
In Netfilter, a few fundamental rule tables are pre-defined, with each table containing built-in chains and
user-defined chains. Tables form the highest layer of organization for Netfilter’s rule sets, and rule chains
form the middle layer, by which individual rules are ordered. Each chain is a list of rules that are applied (or not)
to a packets as they traverse the chains. Each rule specifies what to do with a matching packet. A rule (such as
a jump to a user-defined chain in the same table, or an order to drop a certain type of packet) is also called a
target.
Netfilter is based around three fundamental tables: Filter tables, NAT tables, and Mangle tables. These tables
in turn are structured around a few basic, built-in rule chains. There are five basic rule chains: PREROUTING,
INPUT, FORWARDING, OUTPUT, and POSTROUTING. In addition to these five built-in chains, it is possible for
users to add user-defined chains of their own devising, and insert them into the filtering and mangling
procedures wherever they are needed. Thus, Netfilter may be said to have three layers: the most basic is the
rules layer, the next is the chains layer (which order the rules), and the final is the table layer, which orders the
rule chains.
ATTENTION
For more information on configuring Netfilter/iptables, you may consult the official project website.
Homepage: http://www.netfilter.org/
Documentation: http://www.netfilter.org/documentation/index.html#documentation-howto
Neftilter Extensions: http://www.netfilter.org/documentation/HOWTO//netfilter-extensions-HOWTO.html
3-17
V2101 Series Linux Managing Communications
by Netfilter. To view and manipulate (delete, flush, and add) rule tables, rulechains, and individual rules, refer
to the section below, Manipulating Rulesets.
When the NAT table alters the destination address (on inbound packets, in the PREROUTING chain), it is called
Destination Network Address Translation (DNAT), or Port Forwarding. When the NAT table alters the
source address (on outbound packets, in the POSTROUTING chain), it is called Source Network Address
Translation (SNAT), or IP Masquerading. Netfilter conventions distinguish Masquerading from SNAT in the
following way:
• Masquerading is a form of SNAT where you let your firewall automatically detect the external
interface address
• SNAT refers a situation where you explicitly specify what source address will be used when re-writing
the outbound source address field.
The NAT table does not filter packets. Packet filtering is reserved for the Filter Table.
The NAT table utilizes the built-in PREROUTING, OUTPUT, and POSTROUTING rule chains.
The Filter table uses the built-in INPUT, OUTPUT, and FORWARD rule chains
1. All inbound packets hit the PREROUTING chain, with no exceptions. Any changes performed on the packets
here are done before the routing decision and filtering is done. When connections are bound for machines
located on the local subnet this chain will alter the destination IP address address for destination address
3-18
V2101 Series Linux Managing Communications
translation (DNAT). By the time a packet reaches the PREROUTING chain, all checks on the IP headers have
been completed, but the packet has not yet been routed.
2. The INPUT chain receives all inbound packets which are addressed to the local intranet served by this firewall.
All packets which are addressed to the local intranet will be filtered here, before they continue onwards.
3. The FORWARD chain receives and filters all packets which are addressed to computers which are not located
on the local intranet located behind the firewall, i.e., it redirects packets which are intended to be forwarded to
other parts of the network which are not located on the subnet administered by the firewall, or which have
arrived from sections of the network (not located behind the administered subnet) and are destined for the
open Internet.
4. The OUTPUT chain receives all outbound packets which are addressed to computers outside the local intranet.
All packets which are addressed to the local intranet served by the firewall will be filtered here, before they
continue outwards, onto the Internet.
5. The POSTROUTING chain is the very last chain that is applied; all outbound packets which are leaving the
local machine (or subnet) will pass through this chain. Packets which are processed by the POSTROUTING chain
have already been routed, but have not been sent over the Ethernet. This is where Netfilter performs source
address translation (SNAT), altering the source address forom the IP address that is used on the local
intranet to the one which identifies the firewall on the open Internet.
User-Defined Chains
User-defined chains are used to create customized filters for a wide variety of needs; however, there are some
commonly used chains which most administrators call when building a firewall. One example follows:
Moxa:~moxa@MOXA:~# iptables –N TCP && iptables –N UDP
This creates a user-defned chain called TCP and another called UDP, which you may use to manage protocols
later on. To see how to implement these chains in the INPUT chain, see below, Rule Examples: Applying
User-Defined Chains.
ATTENTION
To find out what rules are currently written into each table and chain, use the commands described below, in
the section Viewing and Manipulating Rulesets.
A) Forwarded packets will traverse this set of chains in the following order:
PREROUTING FORWARD POSTROUTING
(in the NAT table) (in the Filter table) (in the NAT table)
B) Inbound traffic that is destined for the local subnet will traverse this set of chains:
PREROUTING INPUT INPUT
(in the NAT table) (in the Mangle table) (in the Filter table)
C) Outbound traffic that is leaving the firewall will traverse this set of chains:
OUTPUT OUTPUT POSTROUTING
(in the NAT table) (in the Mangle table) (in the Filter table)
ATTENTION
Building complex firewalls using the Netfilter rules and interface can become overwhelming, even for
experienced administrators. If you require advanced firewall capabilities, Moxa recommends using a Netfilter
configuration interface. One of the easiest to learn and most powerful is the Shorewall Firewall. Shorewall is
available as a standard Debian package, and may be downloaded using apt-get. Shorewall documentation is
available at the Shorewall website, found at http://www.shorewall.net.
3-19
V2101 Series Linux Managing Communications
Incoming
Packets
Mangle Table
PREROUTING Chain
NAT Table
PREROUTING Chain
Mangle Table
OUTPUT Chain
NAT Table
OUTPUT Chain
Filter Table
OUTPUT Chain
NAT Table
POSTROUTING Chain
Outgoing
Packets
ATTENTION
Be careful when setting up iptables rules. Incorrectly configured rules can very easily break connectivity with
a remote host. For simple setups requiring minimal configuration (five rules or less), Moxa recommends
directly configuring iptables using the console and a standard editor. For more complicated setups, users may
use Arno’s iptables firewall script, or for very large, extremely complicated setups Moxa recommends the
Shoreline Firewall. The following links will take you to further information about iptables setups and the various
software packages mentioned above.
3-20
V2101 Series Linux Managing Communications
Connection Tracking
A connection tracking system does not filter packets. The Netfilter connection tracking system monitors kernel
memory structures to keep track of the state of each connection; this means that it logs the protocol types, port
number pairs, and source and destination IP addresses, and associates that with various connection states and
timeout values. By being able to track connection states, it is possible to build much more powerful and secure
filtering rules.
• NEW
This is the state when a connection is just initiating: the firewall has only seen traffic in one direction (either
inbound or outbound) and if the packet is a valid one for initating a connection (i.e., a SYN packet for a TCP
request).
• ESTABLISHED
This is used to describe a connection that has been successfully negotiated, and packet are being
exchanged in both directions.
• RELATED
At the application layer there are some protocols—like FTP passive mode, for instance—which are difficult
to track. FTP passive mode uses a wide range of ports, from 1024 to 65535, rather than just one; tracking
in this connections is much more difficult than simply tracking a connection across a single port (typically
port 20, in FTP). The connection tracking system defines an expectation, which is a connection that is
expected to happen in a set period of time, but that has a limited lifetime. Using helpers and expectations,
the Netfilter connection tracking system is able to track connections according to patterns by defining
master connections, and related connections.
• INVALID
This is used to identify packets that do not follow the expected behavior of a connection. Sytems
administrators can set filters to drop them.
The default policy for most firewalls should be an across-the-board drop all connections; after setting the
policies to drop all connections, administrators may then add exceptions to allow connections through on a
case-by-case basis. This section will only show you how to set the policies; o see how to write rules, look at the
section below, Writing Rulechains.
WARNING
Firewall rules are ony valid for the time the computer is on. If the system is rebooted, the rules will be
automatically flushed. To save a ruleset so that it loads on the next reboot, use the following command:
moxa@Moxa:~# /sbin/service iptables save
3-21
V2101 Series Linux Managing Communications
Setting Policies
Moxa:~moxa@MOXA:~# iptables [-t tables] [-P, --policy chain target] [Policy: ACCEPT,
DROP, ETC]
Command Arguments:
-P, --policy: This sets a default policy the firewall will enforce on a particular chain for a particular table.
Only built-in chains (i.e.: not user-defined) can have policies. Possible targets for policy enforcement are
INPUT, OUTPUT, FORWARD, PREROUTING, OUTPUT, and POSTROUTING. Possible policies that may be
enforced on these chains are ACCEPT, DROP, QUEUE, and RETURN (see below for explanation).
INPUT: Targets packets coming into the V2101-LX over the filter, mangle, or security tables.
OUTPUT: Targets locally-generated packets leaving the V2101-LX. All tables have an output chain.
FORWARD: Targets packets routed through the machine, on the filter, mangle, or security tables.
PREROUTING: Targets packets for alteration before they have traversed the firewall; used on the NAT,
mangle, and raw tables.
POSTROUTING: Targets packets as they are about to be sent out over the NAT and mangle tables.
Policy Arguments:
ACCEPT: By default, all packets are let through the chain.
DROP: Packets are dropped, with no notification or response sent back to the originating computer.
QUEUE: Passes the packet to userspace; see NFQUEUE in Netfilter/iptables documentation for more
information about how these targets are used.
RETURN: Stop traversing this chain and resume at the next rule in the previous (calling) chain.
REJECT: Equivalent to DROP, but it returns a message to the packet’s origin.
LOG: Turns on kernel logging for matching packets, printing information on all matching packets on the
kernel log where it may be read using dmesg or syslogd.
ATTENTION
A useful tool for building more complex firewalls is the Shoreline Firewall, or Shorewall. The Shorewall
homepage contains full documentation and software downloads, and may be found at the following URL:
http://www.shorewall.net
3-22
V2101 Series Linux Managing Communications
List current rule chains for a target table, or for all tables
WARNING
Simple commands listing iptable NAT or filter rules will autoload selected kernel modules, including the
connectiong tracking (conntrack) and filter (iptable_filter) modules. On high-capacity production servers, these
modules easily overload and bring the networking system down. Whenever a list command is issued, check the
message buffer (dmesg) to see if drivers have been auto-loaded, and what they are. For more information, see
http://backstage.soundcloud.com/2012/08/shoot-yourself-in-the-foot-with-iptables-and-kmod-auto-loading/.
WARNING
The command moxa@MOXA:~moxa@MOXA:~# iptables –F will flush all iptables rulechains from the kernel,
permanently deleting the firewall and fully exposing the computer to the open Internet. IPtables rules will not
automatically reload following a restart; you must configure your machine to reload them, either using a shell
script or some other firewall package.
You should save your configured firewall in a file so you can conveniently re-load it. The following command will
save all of the current iptables rules to the file /etc/iptables.save (you may name the file whatever
you wish):
You may load the rules contained in this file using the iptables-restore command, as follows:
moxa@MOXA:~moxa@MOXA:~# iptables-restore < /etc/iptables.save
3-23
V2101 Series Linux Managing Communications
Zeroing the counters is sometimes useful when monitoring firewall activity for analysis. When used in
combination with the list argument, the zero argument will give a precise measurement of the number of
packets that have been processed since the last measurement, for all chains, a given chain, or even a given rule
within a chain. The full command to flush rule chains is as follows:
moxa@MOXA:~moxa@MOXA:~# iptables –L –Z -n [chain [rulenum]]
Command Arguments:
-Z: Set the packet and byte counters to zero in all chains, for only a given chain, or only a rule in a chain
Writing Rulechains
In this section we show you how to write rules for a simple industrial network firewall. More complicated
firewalls—such as those serving public networks, or untrusted customers—are beyond the scope of this manual.
For advanced firewall needs, Moxa recommends the use of the Shoreline Firewall (Shorewall) mentioned
above.
MOXA:~moxa@MOXA:~# iptables [-t table] [-AI] [INPUT, OUTPUT, FORWARD] [-io interface]
/
[-p tcp, udp, icmp, all] [-s IP/network] [--sport ports] [-d IP/network] /
[--dport ports] –j [ACCEPT. DROP]
-A: Append one or more rules to the end of the selected chain
-I: Insert one or more rules in the selected chain as the given rule number
-i: Identifies an interface which will received a packet
-o: Identifies an interface over which a packet will be sent
-p: Identifies the protocol to be filtered
-s: Identifies a source address (network name, host name, network IP address, or plain IP address)
--sport: Identifies the source port, or the port where the packet originated
-d: Identifies the destination address (network name, host name, NAT or IP address)
--dport: Identifies the destination port, or the port where the packet will terminate
-j: Jump target. Specifies the target of the rules; i.e., how to handle matched packets.
For example, ACCEPT the packet, DROP the packet, or LOG the packet.
WARNING
For all firewalls using a strict DROP policy on incoming packets, be sure to include a rule that accepts packets
on the loopback interface:
moxa@MOXA:~moxa@MOXA:~# iptables –A INPUT –i lo –j ACCEPT
Examples:
REQUIRED RULE for all firewalls:
Accept all packets from the loopback interface:
moxa@MOXA:~# iptables –A INPUT –i lo –j ACCEPT
RECOMMENDED RULE from the sample firewall provided in Appendix C: Sample Scripts:
Allow all traffic from that belongs to established connections, or new, related traffic:
moxa@MOXA:~# iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
3-24
V2101 Series Linux Managing Communications
RECOMMENDED RULE from the sample firewall provided in Appendix C: Sample Scripts:
Drops all traffic with an invalid state, (e.g. Port Unreachable) when nothing was sent to the host, invalid
headers or checksums, and out-of-sequence packets:
moxa@MOXA:~# iptables -A INPUT -m conntrack --ctstate INVALID -j DROP
Basic Filter Rules show examples of how you can open commonly opened ports:
Web server / HTTP:
moxa@MOXA:~# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Secure-sockets web server / HTTPS:
moxa@MOXA:~# iptables -A INPUT -p tcp --dport 443 -j ACCEPT
Remote SSH Connections (REQUIRED RULE):
moxa@MOXA:~# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Incoming UDP Streams:
moxa@MOXA:~# iptables -A INPUT -p udp --dport 53 -j ACCEPT
ATTENTION
ICMPv6 Neighbor Discovery packets will always be classified INVALID (if you don’t know what this means, you
can probably ignore it). You may accept them with this rule:
moxa@MOXA:~# iptables -A INPUT -p 41 -j ACCEPT
Example 3: DROP all TCP packets from 192.168.1.25 (this rule is only necessary on firewalls where you have
set the INPUT policy to ACCEPT; this is not recommended).
moxa@MOXA:~# iptables –A INPUT –i eth0 –p tcp –s 192.168.1.25 –j DROP
Example 5: ACCEPT all packets from 192.168.0.24 destined for ports 137, 138, and 139 on this computer.
moxa@MOXA:~# iptables –A INPUT –i eth0 –p tcp –s 192.168.0.24 --dport 137:139 –j
ACCEPT
ATTENTION
To use the rule in Examples 8 and 9, below, remember to first load the module ipt_mac:
moxa@MOXA:~# modprobe ipt_mac.
To make a module load across reboots, you may add it to the /etc/modprobe.conf file using this command:
moxa@MOXA:~# echo “ipt_mac” >> /etc/modprobe.conf
Don’t forget to backup your modprobe.conf file before altering it, and take care to use the double pointer
(>>)—which is append—rather the single pointer (>) which is overwrite.
Some network administrators may find it useful to define their own rule chains. Here, we show how to
implement them in the INPUT chain, and use the chains defined above, in the section User-Defined Chains.
3-25
V2101 Series Linux Managing Communications
ATTENTION
A sample firewall is provided in Appendix A: A Sample Firewall.
IP tables policies for the NAT table should all be ACCEPT (see the section above, Netfilter Policy Examples,
for more information):
moxa@MOXA:~# iptables -t nat -P PREROUTING ACCEPT
moxa@MOXA:~# iptables -t nat -P POSTROUTING ACCEPT
moxa@MOXA:~# iptables -t nat -P OUTPUT ACCEPT
Source NAT (SNAT) is when the source address is altered on the first packet of an outbound connection. That
is, it changes the originating address (which is usually a LAN address that looks like 192.168.xxx.xxx) for
outbound packets so that they show the IP address with which the connection to the open internet is
associated.
Destination NAT (DNAT) is when the destination address is altered on the first packet of an outbound
connection. That is, it changes the originating address (which is usually a LAN address that looks like
192.168.xxx.xxx) for outbound packets so that they show the IP address with which the connection to the open
internet is associated.
ATTENTION
Click on the following link for more information about NAT:
http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html
NAT masquerading allows you to create a subnet of devices mapped to a single IP address. When used with port
forwarding and static IP addressing, it can allow you to expand a single public IP address to a very large LAN.
3-26
V2101 Series Linux Managing Communications
ATTENTION
To make a module load across reboots, you may add it to the /etc/modprobe.conf file using this command:
moxa@MOXA:~# echo “ipt_MASQUERADE” >> /etc/modprobe.conf
Don’t forget to backup your modprobe.conf file before altering it, and take care to use the double pointer
(>>)—which is append—rather the single pointer (>) which is overwrite.
In the NAT table (-t nat), Append a rule (-A) after routing (POSTROUTING) all packets going out ppp0 (-o
ppp0) which says to MASQUERADE the connection (-j MASQUERADE).
moxa@MOXA:~# iptables –t nat –A POSTROUTING –o eth0 –s 555.666.777.888/24 –j
MASQUERADE
The most convenient way of guaranteeing that your iptables will automatically reload following a restart is
through the iptables-persistent package. This is a simple script that will record the current iptables
configuration to a set of rules at /etc/iptables/rules.v4. However, administrators will need to re-run the
script every time they update or change the netfilter rules. You may do this by either re-installing the package
(using apt or aptitude), or by using the dpkg-reoconfigure command as below:
moxa@MOXA:~#dpkg-reconfigure iptables-persistent
Another way of setting the firewall to automatically load is by adding two lines (shown below) to your
/etc/rc.local file, or to the /etc/network/interfaces/if-up.d/upstart file:
# Load iptables rules from this file
iptables-restore < /etc/iptables.conf
The following procedures illustrate how to mount a remote NFS Server. 192.168.3.5, in step 3, is the IP
address of the NFS server.
3-27
V2101 Series Linux Managing Communications
ATTENTION
To set up a mount process to mount at boot-time, copy the mount command into the /etc/fstab file.
For more information on NFS and its configuration options, you may refer to the NFS homepage, at:
http://nfs.sourceforge.net/ (Dec. 2013).
Setting Up a VPN
This platform uses the OpenVPN package to provide VPN capability. OpenVPN provides two basic types of
tunnels for users to implement VPNS: Routed IP Tunnels and Bridged Ethernet Tunnels.
An Ethernet bridge is used to connect different Ethernet networks together. The Ethernets are bundled into one
bigger, logical network that can communicate securely across the open Internet. Each Ethernet corresponds to
one physical interface (or port) that is connected to the bridge.
On each OpenVPN machine, you should carry out configurations in the /etc/openvpn directory, where script
files and key files reside. Once established, all operations will be performed in that directory.
Host A represents the machine that belongs to the subnet served by the VPN server, OpenVPN A, and Host
B represents a machine that belongs to the subnet served by the VPN server, OpenVPN B. The two remote
subnets are configured for distinct ranges of IP addresses on separate subnets. When this configuration
is moved to a public network, the external interfaces of the OpenVPN machines must be configured for static
IPs, or connected to another device (such as a firewall or DSL box) that uses a static address. To set up a
bridged Ethernet tunnel following this basic architecture, follow the instructions below:
2. Copy the keyfile that you have just generated to the OpenVPN machines:
moxa@MOXA:~# scp /etc/openvpn/secrouter.key XXX.XXX.X.XXX:/etc/openvpn
3-28
V2101 Series Linux Managing Communications
ATTENTION
Select cipher and authentication algorithms by specifying cipher and auth. To see which algorithms and ciphers
are available, type:
2. Next, modify the routing table in /etc/openvpn/tap0-br.sh script.so that it maps the internal
subnet VPN server A will be serving.
#--------------------------Start---------------------------
#!/bin/sh
# value after “-net” is the subnet behind the remote peer
route add -net 192.168.4.0 netmask 255.255.255.0 dev br0
#----------------------------end---------------------------
#!/bin/bash
# Create global variables
# Define Bridge Interface
br=“br0”
# Define list of TAP interfaces to be bridged,
# for example tap=“tap0 tap1 tap2”.
tap=“tap0”
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth=“eth1”
eth_ip=“192.168.8.173”
eth_netmask=“255.255.255.0”
eth_broadcast=“192.168.8.255”
#gw=“192.168.8.174”
...
3-29
V2101 Series Linux Managing Communications
#----------------------------------Start-----------------------------
#!/bin/sh
# value after “-net” is the subnet behind the remote peer
route add -net 192.168.2.0 netmask 255.255.255.0 dev br0
#---------------------------------- end -----------------------------
#!/bin/bash
# Create global variables
# Define Bridge Interface
br=“br0”
# Define list of TAP interfaces to be bridged,
# for example tap=“tap0 tap1 tap2”.
tap=“tap0”
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth=“eth1”
eth_ip=“192.168.8.174”
eth_netmask=“255.255.255.0”
eth_broadcast=“192.168.8.255”
#gw=“192.168.8.173”
...
9. Start the OpenVPN peers that are on machine OpenVPN A and OpenVPN B with the following command:
moxa@MOXA:~# openvpn --config /etc/openvpn/tap0-br.conf&
If you see a line that looks like Peer Connection Initiated with 192.168.8.173:5000on each machine,
then the connection the Ehternet bridge has been successfully established over UDP port 5000.
10. Check the routing table on each VPN server by typing the command below:
moxa@MOXA:~# route
3-30
V2101 Series Linux Managing Communications
Interface eth1 and device tap0 both connect to the bridging interface, and the virtual device tun sits on
top of tap0. This ensures that all traffic coming to this bridge from internal networks connected to
interface eth1 write to the TAP/TUN device that the OpenVPN program monitors. Once the OpenVPN
program detects traffic on the virtual device, it sends the traffic to its peer.
11. To create an indirect connection to Host B from Host A, you need to add the following routing item:
moxa@MOXA:~# route add –net 192.168.4.0 netmask 255.255.255.0 dev eth0
To create an indirect connection to Host A from Host B, you need to add the following routing item:
moxa@MOXA:~# route add –net 192.168.2.0 netmask 255.255.255.0 dev eth0
A successful ping indicates that you have created a VPN system that only allows authorized users from
one internal network to access users at the remote site. For this system, all data is transmitted by UDP
packets on port 5000 between OpenVPN peers.
12. To shut down the VPN servers, use the killall command:
moxa@MOXA:~# killall -TERM openvpn
Like the last example, this setup will link two subnets across the oopen Ethernet; however, these two subnets
will share addressing as if they were located on the same local subnet.
All of the clients on the two remote subnets are configured for a range of IP addresses that spans the same
subnet. When this configuration is moved to a public network, the external interfaces of the OpenVPN
machines must be configured for static IPs or connected to another device (such as a firewall or DSL box) that
uses a static address.
The configuration procedure for this setup is almost the same as for the previous example. The only difference
is that you will need to comment out the parameter up in the /etc/openvpn/tap0-br.conf on each of the
gateways, OpenVPN A and OpenVPN B.
3-31
V2101 Series Linux Managing Communications
ping 40
#up /etc/openvpn/tap0-br.sh
#comp-lzo
Routed IP Tunnels
Routed IP tunnels are used to route point-to-point IP traffic without broadcasts; the advantage of routed IP
tunnels is that they are slightly more efficient than bridged ethernet tunnels and easier to configure.
3. Host A represents the machine that belongs to the subnet served by the VPN server, OpenVPN A, and
Host B represents a machine that belongs to the subnet served by the VPN server, OpenVPN B. The two
remote subnets are configured for distinct ranges of private IP addresses on separate subnets.
4. On VPN server A (OpenVPN A), modify the remote address entry in the configuration file
/etc/openvpn/tun.conf by adding the address of OpenVPN B. Also, you must add an ifconfig entry
which indicates the local (1st) and remote (2nd) VPN gateway addresses, separated by a space.
5. Next, change OpenVPN A’s /etc/openvpn/tun.sh so that the routing table matches the local subnet
the VPN gateway is serving. Notice the gw $5 appended to the end of this line: the $5 is a variable
argument that OpenVPN passes to the startup script. Its value is the second argument of ifconfig in the
/etc/openvpn/tun.conf file.
#---------------------------Start----------------------------
#!/bin/sh
# value after “-net” is the subnet behind the remote peer
route add -net 192.168.2.0 netmask 255.255.255.0 gw $5
#----------------------------end-----------------------------
3-32
V2101 Series Linux Managing Communications
6. On VPN server B (OpenVPN B), change the remote address in configuration file
/etc/openvpn/tun.conf by adding the address of OpenVPN A. Also, you must add an ifconfig entry
which indicates the local (1st) and remote (2nd) VPN gateway addresses, each separated by a space.
7. Next, change OpenVPN B’s routing table in the file /etc/openvpn/tun.sh so that it matches the local
subnet the VPN gateway is serving. Notice the gw $5 appended to the end of this line: the $5 is a variable
argument that OpenVPN passes to the script file. Its value is the second argument of ifconfig in the
/etc/openvpn/tun.conf file.
#--------------------------Start----------------------------
#!/bin/sh
# value after “-net” is the subnet behind the remote peer
route add -net 192.168.2.0 netmask 255.255.255.0 gw $5
#---------------------------end-----------------------------
8. Check the routing table after you run OpenVPN; it should show an established route running between your
two VPN gateways. The command to see the routing table is:
moxa@Moxa:~# route.
3-33
V2101 Series Linux Managing Communications
ATTENTION
Click on the following links for more information about RFC1317 RS-232 like group and RFC 1213 MIB-II.
http://www.faqs.org/rfcs/rfc1317.html
http://www.ietf.org/rfc/rfc1213.txt
3-34
4
4. Programmer’s Guide
Device API
RTC (Real Time Clock)
UART
Digital I/O
V2101 Series Linux Programmer’s Guide
Device API
The V2101 supports control devices with the ioctl system API. The ioctl() function manipulates the underlying
device parameters of special files. Many operating characteristics of character special files (i.e., character
devices, or terminals) may be controlled with ioctl() requests. The argument d must be an open file
descriptor. The second argument is a device-dependent request code. The third argument is an untyped
pointer to memory.
1. Function: RTC_RD_TIME
Description: reads the time from RTC. It will return the value on argument 3.
int ioctl(fd, RTC_RD_TIME, struct rtc_time *time);
2. Function: RTC_SET_TIME
Description: set RTC time. Argument 3 will be passed to RTC.
int ioctl(fd, RTC_SET_TIME, struct rtc_time *time);
UART
The normal tty device nodes for the UART are /dev/ttyS0 and /dev/ttyS1.
The V2101 supports standard Linux termios control with RS-232/422/485 serial ports.
1. To access the UART in a script you should call the moxadevice.h software library, which you can find in the
folder \example\moxalib on your software CD.
#define RS232_MODE 0
#define RS485_2WIRE_MODE 1
#define RS422_MODE 2
#define RS485_4WIRE_MODE 3
2. The function MOXA_SET_OP_MODE sets the interface mode. The function takes three arguments, and the
third will set the UART device driver to the desired interface.
int ioctl(fd, MOXA_SET_OP_MODE, &mode)
3. The function MOXA_GET_OP_MODE will return the current interface mode as the third argument.
int ioctl(fd, MOXA_GET_OP_MODE, &mode)
There are two Moxa private ioctl definitions for setting up special baudrates. If you use this ioctl to set a special
baudrate, the termios cflag will be B4000000, in which case the B4000000 definition will change. If the
baudrate you get from termios (or from calling tcgetattr()) is B4000000, you must call ioctl with
MOXA_GET_SPECIAL_BAUD_RATE to get the actual baudrate.
MOXA_SET_SPECIAL_BAUD_RATE
MOXA_GET_SPECIAL_BAUD_RATE
4-2
V2101 Series Linux Programmer’s Guide
#include “moxadevice.h”
#include <termios.h>
struct termios term;
int fd, speed;
fd = open(“/dev/ttyS0”, O_RDWR);
tcgetattr(fd, &term);
term.c_cflag &= ~(CBAUD | CBAUDEX);
term.c_cflag |= B4000000;
tcsetattr(fd, TCSANOW, &term);
speed = 500000;
ioctl(fd, MOXA_SET_SPECIAL_BAUD_RATE, &speed);
#include “moxadevice.h”
#include <termios.h>
struct termios term;
int fd, speed;
fd = open(“/dev/ttyS0”, O_RDWR);
tcgetattr(fd, &term);
if ( (term.c_cflag & (CBAUD|CBAUDEX)) != B4000000 ) {
// follow the standard termios baud rate define
} else {
ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed);
}
Moxa’s UART ASIC features two registers: a standard 16 bit register that supports all standard baudrates, and
a secondary register that adds support for non-standard baudrates in the range 50 bps to 921.6 Kbps.
Because serial devices which use non-standard baudrates generally use slower baudrates, supported
baudrates are much denser in the lower range than in the upper (i.e., no baudrates are supported between the
integers 5320 and 5323, but 49 baudrates are supported between the integers 387 and 388).
However, before using a serial device that uses a non-standard baudrate, system engineers should first check
that this computer is compatible with the target baudrate within the accuracy tolerance specified by the serial
device manufacturer.
Use formula B (shown below) to calculate the closest baudrate that can be achieved for any given non-standard
baudrate; if this result falls within the rate tolerance supported by the device, then the computer is compatible
with the target device. In the equations below:
Baudrate represents the desired target baudrate
N represents the multiple to which the standard UART register is set
M represents the value for the secondary register that Moxa devices use to adjust transmission rates
for non-standard devices; M is a number between 0 (representing standard, non-fractional baudrate
multiplier) and 7. In the Moxa UART API, M is represented as ENUM.
As shown in the equations below, Moxa’s secondary register can only be set to intervals of sevenths (e.g, 0.125,
0.250, 0.375, etc.). It is because of this limitation that engineers need to check first and see if the UART
registers are compabtible within a device’s specified transmission tolerances.
4-3
V2101 Series Linux Programmer’s Guide
N is the multiplier for the standard UART register; here, it is any integer between 1 (912,600 bps)
and 18432 (50 bps).
quot =921600 / 100000; // here 100000 is want to set baud rate, 921600 is a constant
which is depended on hardware
outb(cval | UART_LCR_DLAB, info->base + UART_LCR); /* set DLAB * /
outb(quot & 0xff, info->base + UART_DLL); /* LS of divisor */
outb(quot >> 8, info->base + UART_DLM); /* MS of divisor */
outb(cval, info->base + UART_LCR); /* reset DLAB */
SET_MOXA_MUST_ENUM_VALUE(info->base, quot);
Example: Your serial device requires using a baudrate of 5340 bps and has a transmission tolerance of ±2 bps.
Can this computer be used with this device?
Solution: Set formula B to the desired baudrate and then solve for M.
5338 = 8 x 921600/K ==> M = 1367.703259…
This shows that the supported baudrate closest to 5340 comes from setting K to 1367 or 1368.
Because (5338 – Baudrate1) < 2, this computer will transmit at this non-standard rate (Baudrate 1) within the
accuracy tolerance specified by the device.
Note that we can also use formula A to generate the so-called “standard” baudrates, which come from setting
M=0, and setting N equal to certain integers.
4-4
V2101 Series Linux Programmer’s Guide
Standard Baudrates
Baudrate N M Baudrate N M
921600 1 0 4800 192 0
460800 2 0 2400 384 0
230400 4 0 1800 512 0
115200 8 0 1200 768 0
57600 16 0 600 1536 0
38400 24 0 300 3072 0
19200 48 0 150 6144 0
9600 96 0 75 12288 0
7200 128 0 50 18432 0
WARNING
Communication between a serial device and a Moxa UART port may not work correctly if the serial device
communicates at a baud rate that is not within the tolerance of a rate calculated from either formula A or
formula B.
Special Note
1. The termios cflag will only return baudrates from the first register (i.e.: standard baudrates like 50, 75, 110,
2400, 4800, 115200, 230400, 921600, and so forth). If the UART register is configured for a non-standard
baudrate, the termios cflag will not reflect the actual baud rate.
2. Because of the above limitation, if administrators use a serial terminal (stty) to retrieve serial information
about non-standard baudrates, the terminal will return a speed of 0 for any non-standard baudrates.
Digital I/O
Digital output channels can be set to high or low. The channels are controlled by the function call
set_dout_state( ). Use the digital input channels to detect the state change of the digital input signal. The DI
channels can also be used to detect whether or not the state of a digital signal changes during a fixed period of
time. This can be done by the function call, set_din_event( ).
#define DIO_HIGH 1
#define DIO_LOW 0
4-5
V2101 Series Linux Programmer’s Guide
Output none
Return refer to the error code
Function int set_din_event(int diport, void (*func)(int diport), int mode, long int duration)
Description Set the DIN event when the state is changed from high to low or from low to high.
Input <diport> The port that will be used to detect the DIN event.
Port numbering is from 0 to 3. This value depends on your device.
<(*func) (int diport)>
Not NULL: Returns the call back function. When the event occurs, the call back function will
be invoked.
NULL: Clear this event
<mode>
DIN_EVENT_HIGH_TO_LOW (1): From high to low
DIN_EVENT_LOW_TO_HIGH (0): From low to high
DIN_EVENT_CLEAR (-1): Clear this event
<duration>
0: Detect the din event DIN_EVENT_HIGH_TO_LOW or DIN_EVENT_LOW_TO_HIGH
without duration
Not 0: Detect the din event DIN_EVENT_HIGH_TO_LOW or
DIN_EVENT_LOW_TO_HIGH with duration.
Note:
The value of “duration” must be a multiple of 20 milliseconds.
The range of “duration” is 0, or 40 <= duration <= 3600000 milliseconds.
The error of the measurement is 24 ms. For example, if the DIN duration is 200 ms, this
event will be generated when the DIN pin stays in the same state for a time between 176 ms
and 200 ms.
Output None
Return Refer to the error code
4-6
V2101 Series Linux Programmer’s Guide
Special Note
1. The Moxa code library, moxalib, must first be compiled before the digital input and ouput channels can be
enabled. The Moxa library may be found on the software CD included with your computer, in the folder
/media/cdrom/example/moxalib (after mounting the CD in your computer). To build moxalib, call the
GNU program make from the home directory, as an unprivileged user: this will protect the system from
unanticipated corruption that might be introduced during the build process if one were to run it with full root
privileges. In order to compile the library from your home drive you will need to first copy it over from the
software CD. Thus, to compile moxalib you will need to run the following commands:
moxa@Moxa:~# cd /home/
moxa@Moxa:~/home# mkdir code && cd code
moxa@Moxa:~/home/code# cp –a /media/cdrom/example/moxalib .
moxa@Moxa:~/home/code# cd moxalib
moxa@Moxa:~/home/code/moxalib# make all
WARNING
Do not run the make command using root privileges. Doing so could harm your system, and will eliminate
all of the system protections that a user account provides against buggy code and other problems.
Additionally, remember that every time you update the kernel you will need to rebuild this library. If or
and when you upgrade your kernel to a new version you will need to recompile this library, along with any other
kernel modules for third party software you may have installed.
2. If you want to build the DIO sample code, follow this command:
moxa@Moxa:~/home/code/dio# make
Please note that the working directory in this example is /home/code/dio.
3. Make sure to link the library libmoxalib for DI/DO programming, and include the header file
moxadevice.h. Only one program at a time can use the DI/DO library.
4. Due to hardware limitation, you need to modify MIN_DURATION as 60 for V2101.
Description: This program connects Digital Output 1 to Digital Input 1, changes the digital output state to high
or low according to manual input, then detects and counts the state changeds from Digital Input 1.
#include <stdio.h>
#include <stdlib.h>
#ifdef NO_MOXADEVICE_HEADER
#include "moxadevice.h"
#else
#include <moxadevice.h>
#endif
#include <fcntl.h>
/* Due to hardware limitation, MIN_DURATION should be 60 for DA710 */
#define MIN_DURATION 40
static char *DataString[2]={"Low ", "High "};
4-7
V2101 Series Linux Programmer’s Guide
4-8
V2101 Series Linux Programmer’s Guide
4-9
V2101 Series Linux Programmer’s Guide
4-10
5
5. Built-In Linux OS Recovery
The V2101-LX is installed with the Embedded Linux operating system, which is located in the Flash DOM
(CompactFlash card) shipped with the V2101-LX computer. Although it rarely happens, you may find on
occasion that operating system files and/or the disk file system are damaged. This chapter describes how to
recover the Linux operating system.
Recovery Environment
Recovery Procedure
Step 1: Format an Empty USB Disk.
Step 2: Create a Linux Bootable USB Disk.
Step 3: Set up the BIOS to Boot from a USB Disk.
Step 4: Recover the Linux system from a USB Disk.
V2101 Series Linux Built-In Linux OS Recovery
Recovery Environment
The recovery environment includes the V2101-LX embedded computer and a bootable USB disk with the
recovery programs and system image file.
Recovery Procedure
Step 1: Format an Empty USB Disk.
a. Prepare a USB disk that has at least a 256 MB capacity.
b. Format your USB disk with the HP USB Disk Format Tool. Open the
utility and select the device and FAT file system. You need empty disk
only. DO NOT check the option Create a DOS startup disk.
c. Click Start.
ATTENTION
The HP USB Disk Storage Format Tool can be downloaded from many web sites. Do a search on HP USB Disk
Storage Format Tool from any search engine to locate the tool, or you may try the link below:
http://hp-usb-disk-storage-format-tool.soft32.com/free-download/
5-2
V2101 Series Linux Built-In Linux OS Recovery
d. Open a DOS prompt and type M:\syslinux.exe M: to create a bootable Linux disk.
In this example, M: is the USB Disk drive number.
e. Press “+” to move the selection up to the first priority, and press Esc to exit the setup menu.
f. Make sure the first boot device is Hard Disk. If not, press Enter to change it.
g. Select Exit Save & Exit Setup and then press Enter.
h. Choose Y to save to the CMOS and then exit.
ATTENTION
Please note that some USB disks will be regarded as the Removable Device. If it happens, see the following
steps.
5-3
V2101 Series Linux Built-In Linux OS Recovery
j. Make sure that the USB disk has been detected. Press Esc to exit.
k. Make sure that the First Boot Device is Removable. If not, select First Boot Device, press Enter and
select it from the list.
5-4
V2101 Series Linux Built-In Linux OS Recovery
l. Select Exit Save & Exit Setup and then press Enter.
m. Choose Y to save to the CMOS and then exit.
This tool can be used to both backup a Ghost-like image of your hard
disk and to restore your hard disk from such an image. Please, be
aware that if you choose to restore your hard disk. All the data
contained on this computer might be lost during the restoration. You
man choose to abort now, by stopping the computer now.
<OK>
Network share
Local disk partition
<OK> <Cancel>
5-5
V2101 Series Linux Built-In Linux OS Recovery
Choose the partition where to store the back/ where to the backup is
stored?
\
<OK> <Cancel>
5-6
V2101 Series Linux Built-In Linux OS Recovery
i. Choose Yes to start the restoration. After the restoration is finished, the system will halt and you will need
to reboot to restart the restored system.
Yes
No
<OK> <Cancel>
When operation is finished, turn off the computer and remove the USB disk.
ATTENTION
DO NOT turn off the power during system recovery, as the system may crash.
5-7
A
A. Sample Scripts & Firewalls
# Read config
. $<<NAME OF YOUR SCRIPT HERE>>_CONFIG
case "$1" in
start)
echo -n "Starting <<name of your script here>> "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
startproc $<<NAME OF YOUR SCRIPT HERE>>_BIN
5-2
V2101 Series Linux Built-In Linux OS Recovery
rc_status -v
;;
stop)
echo -n "Shutting down <<name of your script here>> "
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.
5-3
V2101 Series Linux Built-In Linux OS Recovery
exit 1
;;
esac
rc_exit
A Sample Firewall
#!/bin/bash
# If you put this shell script in the /home/nat.sh
# Remember to chmod 744 /home/nat.sh
# Edit the rc.local file to make this shell startup automatically.
# vi /etc/rc.local
# Add a line in the end of rc.local /home/nat.sh
EXIF= “eth0” #This is an external interface for setting up a valid IP address.
EXNET= “192.168.4.0/24” #This is an internal network address.
# Step 1. Insert modules.
# Here 2> /dev/null means the standard error messages will be dump to null device.
modprobe ip_tables 2> /dev/null
modprobe ip_nat_ftp 2> /dev/null
modprobe ip_nat_irc 2> /dev/null
modprobe ip_conntrack 2> /dev/null
modprobe ip_conntrack_ftp 2> /dev/null
modprobe ip_conntrack_irc 2> /dev/null
# Step 2. Define variables, enable routing and erase default rules.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
echo “1” > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -Z
/sbin/iptables -F -t nat
/sbin/iptables -X -t nat
/sbin/iptables -Z -t nat
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
# Step 3. Enable IP masquerade.
#ehco 1 > /proc/sys/net/ipv4/ip_forward
#modprobe ipt_MASQUERADE
#iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE
5-4