Moxa V2416A User Manual

V2416A Linux User’s Manual
Edition 1.0, September 2015
www.moxa.com/product
© 2015 Moxa Inc. All rights reserved.
V2416A Linux User’s Manual
Moxa Amer
Toll
Tel:
Fax:
Moxa China (Shanghai office)
Toll
Tel:
Fax:
Moxa Europe
Tel:
Fax:
Moxa Asia
Tel:
Fax:
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.
© 2015 Moxa Inc. All rights reserved.
Trademarks
The MOXA logo is a registered trademark of Moxa Inc.
All other trademarks or registered marks in this manual belong to their respective manufacturers.
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.
Technical Support Contact Information
www.moxa.com/support
icas
-free: 1-888-669-2872
+1-714-528-6777
+1-714-528-6778
+49-89-3 70 03 99-0
+49-89-3 70 03 99-99
-free: 800-820-5036
+86-21-5258-9955
+86-21-5258-5505
+886-2-8919-1230
-Pacific
+886-2-8919-1231
Table of Contents
1. Introduction ...................................................................................................................................... 1-1
Overview ........................................................................................................................................... 1-2
Software Specifications........................................................................................................................ 1-2
Software Components ......................................................................................................................... 1-3
2. Software Configuration ..................................................................................................................... 2-1
Account Management .......................................................................................................................... 2-2
Starting from a DVI Console ................................................................................................................. 2-2
Setting up a Desktop Environment ........................................................................................................ 2-3
Connecting from an SSH Console .......................................................................................................... 2-4
Windows Users ........................................................................................................................... 2-4
Linux Users ................................................................................................................................ 2-5
Adjusting the System Time .................................................................................................................. 2-5
Setting the Time Manually ............................................................................................................ 2-5
NTP Client .................................................................................................................................. 2-6
Updating the Time Automatically ................................................................................................... 2-6
Enabling and Disabling Daemons .......................................................................................................... 2-7
Cron—Daemon for Executing Scheduled Commands ................................................................................ 2-8
Inserting a USB Storage Device into the Computer ................................................................................. 2-8
Audio Playback and Recording .............................................................................................................. 2-9
Checking the Linux Version ................................................................................................................ 2-11
APT—Installing and Removing Packages .............................................................................................. 2-11
Wake on LAN ................................................................................................................................... 2-13
3. Managing Communications ............................................................................................................... 3-1
Detecting Network Interfaces ............................................................................................................... 3-2
Changing the Network Settings ............................................................................................................ 3-2
Changing the “interfaces” Configuration File ................................................................................... 3-2
Adjusting IP Addresses with “ifconfig” ............................................................................................ 3-3
Serial Port Operation Mode .................................................................................................................. 3-4
DNS Client ......................................................................................................................................... 3-4
/etc/hostname ............................................................................................................................ 3-4
/etc/resolv.conf ........................................................................................................................... 3-4
/etc/nsswitch.conf ....................................................................................................................... 3-5
Configuring Ethernet Bonding ............................................................................................................... 3-5
Apache Web Server ............................................................................................................................. 3-7
Default Homepage ....................................................................................................................... 3-7
IPTABLES .......................................................................................................................................... 3-7
IPTABLES Hierarchy ..................................................................................................................... 3-8
IP TABLE S Modules ....................................................................................................................... 3-9
Observe and Erase Chain Rules ..................................................................................................... 3-9
Define Policy for Chain Rules ....................................................................................................... 3-10
Append or Delete Rules .............................................................................................................. 3-10
NAT (Network Address Translation) ..................................................................................................... 3-11
NAT Example ............................................................................................................................ 3-12
Enabling NAT at Bootup .............................................................................................................. 3-12
PPP (Point to Point Protocol) ............................................................................................................... 3-13
Connecting to a PPP Server over a Simple Dial-up Connection ......................................................... 3-13
Connecting to a PPP Server over a Hard-wired Link ........................................................................ 3-14
Checking the Connection ............................................................................................................ 3-14
Setting up a Machine for Incoming PPP Connections ...................................................................... 3-15
PPPoE .............................................................................................................................................. 3-16
NFS (Network File System) Client ....................................................................................................... 3-18
SNMP .............................................................................................................................................. 3-19
OpenVPN ......................................................................................................................................... 3-21
Ethernet Bridging for Private Networks on Different Subnets ........................................................... 3-21
Ethernet Bridging for Private Networks on the Same Subnet ........................................................... 3-24
Routed IP ................................................................................................................................. 3-25
4. Programming Guide .......................................................................................................................... 4-1
Device API ......................................................................................................................................... 4-2
Getting the Product Serial Number ........................................................................................................ 4-2
RTC (Real Time Clock) ......................................................................................................................... 4-3
Digital I/O.......................................................................................................................................... 4-3
Special Note ............................................................................................................................... 4-5
Examples ................................................................................................................................... 4-5
WDT (Watch Dog Timer) ...................................................................................................................... 4-5
Introduction................................................................................................................................ 4-5
Watchdog Usage ......................................................................................................................... 4-5
How the WDT Works .................................................................................................................... 4-6
Watchdog Device IOCTL Commands............................................................................................... 4-7
Examples ................................................................................................................................... 4-8
5. Managing the Disk ............................................................................................................................. 5-1
Hot-Swapping Function........................................................................................................................ 5-2
Installing the hotswap driver and daemon ...................................................................................... 5-2
File Overview .............................................................................................................................. 5-2
Configuring the Hot-Swapping Daemon .......................................................................................... 5-2
Handling an Event with the Hot-Swapping Daemon .......................................................................... 5-2
Logging the Hot-Swapping Daemon Message .................................................................................. 5-3
Software RAID—mdadm ...................................................................................................................... 5-4
Create Software RAID Volume ....................................................................................................... 5-4
Check Software RAID Status ......................................................................................................... 5-6
Replacing a Failed Disk ................................................................................................................. 5-6
Removing RAID ........................................................................................................................... 5-7
6. System Recovery ............................................................................................................................... 6-1
Recovery Environment ........................................................................................................................ 6-2
Recovery Procedure ............................................................................................................................ 6-2
Saving the System to the USB Drive ................................................................................................... 6-11
A. Software Components ....................................................................................................................... A-1
1

1. Introduction

Thank you for purchasing the Moxa V2416A series of x86 ready-to-run embedded computers. This manual
introduces the software configuration and management of the V2416A, which runs the Linux operating system.
For hardware installation, connector interfaces, setup, and upgrading the BIOS, please refer to the “V2416A
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.
The following topics are covered in this chapter:
Overview
Software Specifications
Software Components
V2416A Linux Introduction
1-2
ATTENTION
Refer to
Debian GNU/Linux and
ATTENTION
The a
Linux
operating system may include components
Hardware
Micro Kernel
Device Driver
Protocol
API AP
Linux Kernel

Overview

V2416A series EN 50155-certified embedded computers are based on the Intel® Celeron® 1047UE Processor
or Intel® Core™ i7-3517UE Processor. The V2416A computers feature four serial ports, dual 10/100 Mbps or
10/100/1000 LAN ports, three USB 2.0 hosts, and come with two DVI-I outputs. with EN 50155 certification,
the computers are robust enough for railway and industrial applications.
The V2416A’s four serial ports make it ideal for connecting a wide range of serial devices, and the dual 10/100
Mbps or 10/100/1000 Ethernet ports offer a reliable solution for network redundancy, which taken together
promise continuous data communication and management operations. For added convenience, the V2416A
computers have 6 DIs and 2 Dos. In addition, the USB ports provide V2416A computers with data buffering
and storage expansion, which provide the necessary reliability for industrial applications.
Pre-installed with Linux, the V2416A series provides programmers with a friendly environment for developing
sophisticated, bug-free application software at a lower cost.
All V2416A models support a wide operating temperature range of -40 to 70°C for use in harsh industrial
environments.

Software Specifications

The Linux operating system pre-installed on the V2416A embedded computers (CTO models) is the Debian
Wheezy 7.8 distribution. The Debian project involves a worldwide group of volunteers who endeavor to
produce an operating system distribution 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:
Stack
User Applications
Application Interface (POSIX, Socket, Secure Socket)
TCP, IP, UDP, CMP, ARP, HTTP, SNMP, SMTP
PCMCIA, CF, WLAN, USB, UART, RTC, VGA
Memory Control, Schedule, Process
RS-232/422/485, Ethernet, CFast, SATA, USB
Daemon (Apache, Telnet, FTPD)
File
System
http://www.debian.org/ and http://www.gnu.org/ for information and documentation related to
bove software architecture is only an example. Different models or different build revisions of the
the free software concept.
not shown in the above graphic.
V2416A Linux Introduction
1-3

Software Components

The V2416A Linux models are pre-installed with the Debian Wheezy7.8 Linux distribution. For the software
components, see “Appendix A.”
2

2. Software Configuration

In this chapter, we explain how to operate a V2416A-LX computer directly from your desktop. There are two
ways to connect to the V2416A-LX computer: through a DVI monitor, or via an SSH console from a Windows
or Linux machine. This chapter describes basic Linux operating system configurations. Advanced network
management and configuration instructions will be described in the next chapter, “Managing
Communications.”
The following topics are covered in this chapter:
Account Management
Starting from a DVI Console
Setting up a Desktop Environment
Connecting from an SSH Console
Windows Users
Linux Users
Adjusting the System Time
Setting the Time Manually
NTP Client
Updating the Time Automatically
Enabling and Disabling Daemons
Cron—Daemon for Executing Scheduled Commands
Inserting a USB Storage Device into the Computer
Audio Playback and Recording
Checking the Linux Version
APT—Installing and Removing Packages
Wake on LAN
V2416A Linux Software Configuration
2-2
login as: moxa
moxa@Moxa:~#

Account Management

Connect the V2416A to a display, turn on the computer, and then enter the following information to log in the
computer.
Login: moxa
Password: moxa
For security reasons, the root account is already disabled. We strongly suggest changing the password during
the first login. After successfully logging in, you can set up a new password.
moxa@192.168.27.42's password:
You are required to change your password immediately (root enforced)
Linux Moxa 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt4-3~bpo70+1 (2015-02-12) x86_64
#### #### ###### ####### ###### ##
### #### ### ### #### #### ###
### ### ### ### ### ## ###
### #### ## ## ### # ####
#### # ## ### ### ### ## ## ##
## ## # ## ### ## #### # ##
## ### ## ## ## ## #### # ###
## ## # ## ## ## ### #######
## ## # ## ### ### ##### # ##
## ### ## ### ### ## ### # ###
## ### ## ## ## ## ### ## ##
## ### ## ## ## # ### # ##
###### # ###### ######## ####### ########### ######
For further information check:
http://www.moxa.com/

Starting from a DVI Console

When you finish changing the password, remember to type sudo each time you want to run commands with
privilege as the root. For example, typing sudo ifconfig eth0 192.168.100.100 will allow you to configure
the IP address of the LAN 1 port.
Connect the display monitor to the V2416A-LX DVI connector, and then power it up by connecting it to the
power adaptor. It takes approximately 30 to 60 seconds for the system to boot up. Once the system is ready,
a login screen will appear on your monitor.
To log in, type the login name and password as requested. The default values are both moxa.
Login: moxa
Password: moxa
V2416A Linux Software Configuration
2-3
Moxa login: moxa
moxa@MOXA:~# sudo apt-get install gnome-core
moxa@MOXA:~# sudo apt-get install kde-standard
moxa@MOXA:~# apt-get install xfce4 xfce4-goodies thunar-archive-plugin
moxa@MOXA:~# sudo apt-get install lxde-core
Password:
Linux Moxa 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt4-3~bpo70+1 (2015-02-12)
x86_64
#### #### ###### ####### ###### ##
### #### ### ### #### #### ###
### ### ### ### ### ## ###
### #### ## ## ### # ####
#### # ## ### ### ### ## ## ##
## ## # ## ### ## #### # ##
## ### ## ## ## ## #### # ###
## ## # ## ## ## ### #######
## ## # ## ### ### ##### # ##
## ### ## ### ### ## ### # ###
## ### ## ## ## ## ### ## ##
## ### ## ## ## # ### # ##
###### # ###### ######## ####### ########### ######
For further information check:
http://www.moxa.com/

Setting up a Desktop Environment

This section introduces the desktop environment for the V2416A series. By default, the V2416A Linux
operating system models do not install a desktop environment. Debian supports all kinds of fully-featured
graphical environments, such as Gnome, KDE, and lighter environments like Xfce and LXDE. You can choose
to install one of these desktop systems on the V2416A. To do this, use the following commands:
To install Gnome:
To install KDE:
To install Xfce:
To install the minimum LXDE:
V2416A Linux Software Configuration
2-4
LAN 1
192.168.3.127
255.255.255.0

Connecting from an SSH Console

The V2416A computers support the SSH console to offer users better network security compared to Telnet.
The default IP addresses and netmasks of the network interfaces are as follows:
Default IP Address Netmask
LAN 2 192.168.4.127 255.255.255.0
Before using the ssh 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 will connect to. For example,
if you connect to LAN1, 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 LAN2, you could 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 moxa.
Login: moxa
Password: moxa

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 V2416A in a Windows environment. The following screen
shows an example of the configuration that is required.
V2416A Linux Software Configuration
2-5
[root@bee_notebook root]# ssh 192.168.3.127
Are you sure you want to continue connection (yes/no)? yes_
root@Moxa:~# date
root@Moxa:~#

Linux Users

From a Linux machine, use the ssh command to access the V2416A-LX’s console utility via SSH.
# ssh 192.168.3.127
Select yes to open the connection.
The authenticity of host ‘192.168.3.127 (192.168.3.127)’ can’t be established.
RSA key fingerprint is 8b:ee:ff:84:41:25:fc:cd:2a:f2:92:8f:cb:1f:6b:2f.

Adjusting the System Time

The V2416A-LX has two time settings. One is the system time, and the other is provided by an RTC (Real Time
Clock) built into the V2416A-LX’s hardware.

Setting the Time Manually

Use the date command to query the current system time or to set a new system time. Use hwclock to query
the current RTC time or to set a new RTC time.
Use the following command to set the system time.
# date MMDDhhmmYYYY
MM: Month
DD: Date
hhmm: Hour and Minute
YYYY: Year
Use the following command to write the current system time to the RTC.
# hwclock –w
Wed Dec 16 03:34:46 CST 2009
root@Moxa:~# hwclock
Wed 16 Dec 2009 03:35:16 AM CST -0.017600 seconds
root@Moxa:~# date 121616352009
Wed Dec 16 16:35:00 CST 2009
root@Moxa:~# hwclock –w
root@Moxa:~# date ; hwclock
Wed Dec 16 16:36:12 CST 2009
Wed 16 Dec 2009 04:36:13 PM CST -0.016751 seconds
V2416A Linux Software Configuration
2-6
root@Moxa:~# date ; hwclock
root@Moxa:~#
ATTENTION
Before using the NTP client utility, check your IP address and network settings (gateway and DNS)
sure an Internet connection is available.
#!/bin/sh
# Change 100 to a larger number to update RTC less often.

NTP Client

The V2416A-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
Visit http://www.ntp.org for more information about NTP and NTP server addresses.
Wed Dec 16 16:36:12 CST 2009
Wed 16 Dec 2009 04:36:13 PM CST -0.016751 seconds
root@Moxa:~#
root@Moxa:~# ntpdate time.stdtime.gov.tw
16 Dec 03:49:48 ntpdate[2510]: step time server 220.130.158.52 offset 155905087.9
84256 sec
root@Moxa:~#
root@Moxa:~# hwclock -w
root@Moxa:~# date ; hwclock
Wed Dec 16 03:51:07 CST 2009
Wed 16 Dec 2009 03:51:07 AM CST -0.016771 seconds

Updating the Time Automatically

This section describes how to use a shell script to update the time automatically.
Example shell script for updating the system time periodically
ntpdate time.stdtime.gov.tw
# You can use the time server’s ip address or domain
# name directly. If you use domain name, you must
# enable the domain client on the system by updating
# /etc/resolv.conf file.
hwclock –w
sleep 100
# Updates every 100 seconds. The min. time is 100 seconds.
to make
Save the shell script using any file name. For example, fixtime.
How to run the shell script automatically when the kernel boots up
Copy the example shell script fixtime to the directory /etc/init.d, and then use chmod 755 fixtime
to change the shell script mode.
# chmod 755 fixtime
Next, use vi editor to edit the file /etc/inittab.
# vi /etc/inittab
V2416A Linux Software Configuration
2-7
moxa@Moxa:~$ sudo insserv –d apache2
moxa@Moxa:~$ sudo insserv -r apache2
moxa@Moxa:~$ sudo /etc/init.d/apache2 start
moxa@Moxa:~$ sudo /etc/init.d/apache2 stop
root@Moxa:~# cd /etc/
root@Moxa:/etc/# vi rc.local
# !/bin/sh
home/daemon &~
Add the following line to the bottom of the file:
ntp : 2345 : respawn : /etc/init.d/fixtime
After you finish writing or modifying the code, remember to execute umount / to change the root directory
back to Read-only mode.
# umount /
Use the command #init q to re-initialize the kernel.
# init q

Enabling and Disabling Daemons

Only the following daemons are enabled in the V2416A-LX by default:
sftpd SFTP Server / Client daemon
sshd Secure Shell Server daemon
You may manage what services to run in the background by the command insserv. Below example shows how
to add the apache daemon in current runlevel.
Apache will not activate in the current boot session, but will be running in the background from the next boot
session. To disable the apache daemon, use the following command:
Linux daemons can be started or stopped in the current boot session by using of the scripts in /etc/init.d. To
start the apache daemon, use:
To stop the apache daemon, use:
1. To run a private daemon, you can edit the file rc.local, as shown below (type cd /etc/ to change
directories):
2. Type vi rc.local to edit the configuration file with vi editor.
3. Next, add the application daemon that you want to run. The following example shows how to add a daemon
that is placed in the /home/ directory. The daemon will run in the background during system boot.
# Add you want to run daemon
V2416A Linux Software Configuration
2-8
#minute hour date month week user command
* 8 * * * root /path/to/your/program
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
/dev/sdb1 on /media/usb1 type vfat

Cron—Daemon for Executing Scheduled Commands

The Cron daemon will search /etc/crontab for crontab files. Cron wakes up every minute and checks each
command to see if it should be run at that time. 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:
mm h dom mon dow user command
minute hour date month week user command
0-59 0-23 1-31 1-12 0-6 (0 is Sunday)
For example, issue the following command if you want to launch a program at 8:00 every day:
The following example demonstrates how to use Cron to update the system time and RTC time every day at
8:00.
1. Write a shell script named fixtime.sh and save it to
#!/bin/sh
ntpdate time.stdtime.gov.tw
hwclock –w
exit 0
2. Change the mode of fixtime.sh
# chmod 755 fixtime.sh
3. Modify the /etc/crontab file to run fixtime.sh at 8:00 every day.
Add the following line to the end of crontab:
* 8 * * * root /home/fixtime.sh

Inserting a USB Storage Device into the Computer

Since mounting USB storage devices manually can be difficult, a Debian package named usbmount is used to
mount the USB drivers automatically. usbmount relies on udev to mount USB storage devices automatically
at certain mount points. The USB storage devices will be mounted on /media/usb0, /media/usb1, etc.
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=494659,mode=755)
devpts on /dev/pts type devpts
(rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=397292k,mode=755)
/dev/disk/by-label/V2400A_MOXA on / type ext4
(rw,noatime,errors=remount-ro,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=794560k)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
(rw,noexec,nodev,sync,noatime,gid=25,dmask=0007,fmask=0117)
/home/.
V2416A Linux Software Configuration
2-9
(rw,noexec,nodev,sync,noatime,gid=25,dmask=0007,fmask=0117)
root@MOXA:~#
root@MOXA:~# apt-get remove usbmount
root@MOXA:~# apt-get install gnome-volume-manager
ATTENTION
Remember to type the
# 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
umount /media/usb0 to un
root@Moxa:~# alsamixer
Note that usbmount is a light-weight solution for text mode, and does not fully support the gnome desktop
environment. For better supportability, install gnome-volume-manager instead of usbmount:
command
-mount process will fail. If that happens, type #
-mount the USB device manually.

Audio Playback and Recording

The V2416A has a built-in audio system that provides the Line-in, line-out interface in M12 format for audio
playback or recording. Use the following commands to play back audio on the V2416A.
Control the volumn of the Master with alsamixer
Press <TAB> to select the Master as the playback source and press <UP> and <DOWN> to adjust the
volume.
Play a wave file
V2416A Linux Software Configuration
2-10
root@Moxa:~# aplay –t wav /PATH/TO/test.wav
root@Moxa:~# alsamixer
moxa@MOXA:~# arecord -t wav -f cd -c 2 /dev/shm/aaa.wav
The V2416A has a Line-in interface for recording audio. Use the following commands to record audio on the
V2416A.
Control the volume of Capture with alsamixer
Press <F6> to Select the device - “HDA Intel PCH”
Press <TAB> to select the Line and Capture as capture and press <UP> and <DOWN> to adjust the volume.
Record the audio in wave format
V2416A Linux Software Configuration
2-11
root@Moxa:~# uname -a
root@Moxa:~#
root@Moxa:~# vi /etc/apt/sources.list
deb-src http://ftp.debian.org/debian wheezy-backports main contrib non-free
root@Moxa:~# sudo vi /etc/apt/sources.list
deb http://debian.moxa.com/debian wheezy main
root@Moxa:~# apt-key list
sub 2048R/F7F3CD9E 2014-05-28 [expires: 2024-05-25]

Checking the Linux Version

The program uname, which stands for “Unix Name” and is part of the Unix operating system, prints the name,
version, and other details about the operating system running on the computer. Use the -a option to generate
a response similar to the one shown below:
Linux Moxa 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt4-3~bpo70+1 (2015-02-12)
x86_64 GNU/Linux

APT—Installing and Removing Packages

APT is the Debian tool used to install and remove packages. Before installing a package, you need to configure
the apt source file, /etc/apt/sources.list, which is not a read only partition.
1. Use vi editor to configure /etc/apt/sources.list.
deb http://debian.moxa.com/debian wheezy main
deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free
deb http://ftp.debian.org/debian wheezy-backports main contrib non-free
2. Add Moxa’s apt repository
For adding or updating the drivers, libraries, and utilities provided by Moxa.
“deb http://debian.moxa.com/debian wheezy main” is added to the source list by default. If you delete it,
You should add “deb http://debian.moxa.com/debian wheezy main” to the source list.
Moxa has encrypted the packages with a GPG key that allows you to check if the package was verified by us.
The GPG key should be added before starting the installation. You can find the GPG key on the CD or on Moxa’s
website. Upload the key to the Moxa embedded computer and then add it.
Check your GPG key list to verify that “MOXA SYS” is in the list.
/etc/apt/trusted.gpg
--------------------
pub 2048R/62B24532 2014-05-28 [expires: 2024-05-25]
uid MOXA SYS <sys.support@moxa.com>
V2416A Linux Software Configuration
2-12
root@Moxa:~# apt-key add NEW-MOXA-SYS-DEBIAN-KEY
root@Moxa:~# apt-get update
Reading package lists... Done
moxa@MOXA:~# sudo apt-get update
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get install ipsec-tools
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get remove ipsec-tools
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get remove ipsec-tools --purge
moxa@MOXA:~#
ATTENTION
The APT cache space /
/
se
df
moxa@MOXA:~# df -h
moxa@MOXA:~#
ATTENTION
Use
If “MOXA SYS” is not in your list, can add it into the GPG key list.
Next, update the package list to display the most up-to-date package list.
Ign http://debian.moxa.com wheezy Release.gpg
Ign http://debian.moxa.com/debian/ wheezy/main Translation-en
Ign http://debian.moxa.com/debian/ wheezy/main Translation-en_HK
Get:1 http://debian.moxa.com wheezy Release [1,633 B]
Ign http://debian.moxa.com wheezy/main i386 Packages
Get:2 http://debian.moxa.com wheezy/main i386 Packages [1,585 B]
Fetched 3,218 B in 0s (47.2 kB/s)
After updating the package list, use apt-get to install or upgrade the packages from Moxa’s apt repository.
1. Update the source list after you configure it.
2. Once you indicate which package you want to install (ipsec-tools, for example), type:
3. Use one of the following commands to remove a package:
a. For a simple package removal:
b. For a complete package removal:
var/cache/apt to a USB mass storage device or mount it to an NFS space to generate more free space. U
–h to check how much free space is available in tmpfs.
var/cache/apt is located in tmpfs. If you need to install a huge package, link
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 923M 6.2G 13% /
udev 10M 0 10M 0% /dev
tmpfs 388M 184K 388M 1% /run
/dev/disk/by-label/V2400A_MOXA 7.3G 923M 6.2G 13% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 776M 0 776M 0% /run/shm
the command # apt-get clean to free up the cache space.
V2416A Linux Software Configuration
2-13
moxa@MOXA:~# apt-get clean
moxa@MOXA:~#
root@Moxa:/# ethtool eth0
Moxa:/#
etherwake -b 00:90:e8:00:d7:07
etherwake -b 00:90:e8:00:d7:07

Wake on LAN

The V2416A-LX supports wake on LAN, a feature used to wake up a device for suspend (S3) and shutdown
(S5).
To check the WOL support on Ethernet port x, type ethtool ethx, where “x” is the port number.
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: ug
Current message level: 0x00000033 (51)
Link detected: yes
As you can see, the default WOL support is g (wake on Magic packet).
The following example illustrates how to wake up on suspend (S3):
1. Moxa’s embedded computer
Get its MAC by issuing “ifconfig ethx” (x is the port number)
Suspend to RAM with command “pm-suspend --quirk-s3-bios”
Remote computer
Issue the command etherwake -b mac_of_this_device to wake it up. For example:
The following example illustrates how to wake up on shutdown (S5):
1. Moxa’s embedded computer
Shut down your computer with “shutdown -h now”
2. Remote computer
Issue the command etherwake -b mac_of_this_device to wake it up. For example:
3

3. Managing Communications

The V2416A-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 following topics are covered in this chapter:
Detecting Network Interfaces
Changing the Network Settings
Changing the “interfaces” Configuration File
Adjusting IP Addresses with “ifconfig”
Serial Port Operation Mode
DNS Client
/etc/hostname
/etc/resolv.conf
/etc/nsswitch.conf
Configuring Ethernet Bonding
Apache Web Server
Default Homepage
IPTABLES
IPTABLES Hierarchy
IPTABLES Modules
Observe and Erase Chain Rules
Define Policy for Chain Rules
Append or Delete Rules
NAT (Network Address Translation)
NAT Example
Enabling NAT at Bootup
PPP (Point to Point Protocol)
Connecting to a PPP Server over a Simple Dial-up Connection
Connecting to a PPP Server over a Hard-wired Link
Checking the Connection
Setting up a Machine for Incoming PPP Connections
PPPoE
NFS (Network File System) Client
SNMP
OpenVPN
Ethernet Bridging for Private Networks on Different Subnets
Ethernet Bridging for Private Networks on the Same Subnet
Routed IP
V2416A Linux Managing Communications
3-2
# PCI device 0x10ec:/sys/devices/pci0000:00/0000:00:1c.1/0000:02:00.0 (r8169)
KERNEL==“eth*”, NAME=“eth1”
ATTENTION
When
/etc/udev/rules.d/70
abnormally
and
reboot the system.
root@MOXA:~# cd /etc/network
root@MOXA:/etc/network# vi interfaces

Detecting Network Interfaces

Debian Linux systems use udevd to detect new network interfaces, including Ethernet interfaces and wireless
interfaces. One of the rules is /lib/udev/rules.d/75-persistent-net-generator.rules for creating a
persistent network interface naming order. The content in /etc/udev/rules.d/70-persistent-net.rules is
similar to the following:
SUBSYSTEM==“net”, ACTION==“add”, DRIVERS==“?*”,
ATTR{address}==“00:90:e8:00:00:20”, ATTR{dev_id}==“0x0”, ATTR{type}==“1”,
KERNEL==“eth*”, NAME=“eth0”
# PCI device 0x10ec:/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0 (r8169)
SUBSYSTEM==“net”, ACTION==“add”, DRIVERS==“?*”,
ATTR{address}==“00:90:e8:00:00:21”, ATTR{dev_id}==“0x0”, ATTR{type}==“1”,
The above example indicates that the system has detected two Ethernet interfaces.
replacing or connecting a network interface, the system may keep the old record in
-persistent-net.rules, which could cause network interfaces to be detected
. To avoid this problem, delete the content of the file /etc/udev/rules.d/70-persistent-net.rules

Changing the Network Settings

The V2416A-LX computer has two 10/100 or 10/100/1000 Ethernet ports named LAN1 and LAN2. The default
IP addresses and netmasks of these network interfaces are:
Default IP Address Netmask
LAN1 192.168.3.127 255.255.255.0
LAN2 192.168.4.127 255.255.255.0
These network settings can be modified by changing the interfaces configuration file, or they can be adjusted
temporarily with the ifconfig command.

Changing the “interfaces” Configuration File

1. Type cd /etc/network to change directories.
2. Type vi interfaces to edit the network configuration file with vi editor. You can configure the V2416A-LX’s
Ethernet ports for static or dynamic (DHCP) IP addresses.
V2416A Linux Managing Communications
3-3
# The loopback network interface
broadcast 192.168.4.255
# The primary network interface
iface eth0 inet dhcp
root@MOXA:~# /etc/init.d/networking restart
root@MOXA:~# ifconfig eth0 192.168.1.1
root@MOXA:~#
Static IP Address
As shown in the following example, the default static IP addresses can be modified.
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.127
netmask 255.255.255.0
broadcast 192.168.3.255
auto eth1
iface eth1 inet static
address 192.168.4.127
netmask 255.255.255.0
Dynamic IP Address using DHCP
To configure one or both LAN ports to request an IP address dynamically, replace static with dhcp and then
delete the rest of the lines.
auto eth0
After modifying the boot settings of the LAN interface, issue the following command to activate the LAN
settings immediately.
# /etc/init.d/networking restart

Adjusting IP Addresses with “ifconfig”

IP settings can be adjusted during run-time, but the new settings will not be saved to the flash ROM without
modifying the file /etc/network/interfaces. For example, type the command # ifconfig eth0
192.168.1.1 to change the IP address of LAN1 to 192.168.1.1.
V2416A Linux Managing Communications
3-4
-h
Help
-g
Get information
-i intf
Set interface type
intf
RS232
RS422
RS4852W
RS4854W
RS-232 mode
RS
RS
RS-485 4 wire mode
root@Moxa:~# muestty -i RS422 /dev/ttyMUE0
root@Moxa:~#
moxa@MOXA:~# sudo vi /etc/hostname
Moxa
root@Moxa:~# /etc/init.d/hostname.sh start
root@Moxa:~# hostname

Serial Port Operation Mode

The V2416A-LX computer has 4 serial ports named COM1, COM2, COM3, and COM4. The ports support RS-232,
RS-422, 2-wire RS-485, and 4-wire RS-485 operation modes with baudrate settings up to 921600 bps.
By default, the serial interface is set to RS-232. You can use the muestty command to change the serial port
operation mode, as indicated below:
muestty <operation> devicedevice-node: /dev/ttyMUEn; n = 0,1,2,...
<operation> [see following table]:
For example, use the following commands to set /dev/ttyMUE0 to RS-422:
muestty: Set interface of /dev/ttyMUE0 ok.
root@Moxa:~# muestty -g /dev/ttyMUE0
muestty: /dev/ttyMUE0 is set to RS-422 mode.

DNS Client

The V2416A-LX supports DNS client (but not DNS server). To set up DNS client, you need to edit three
configuration files: /etc/hostname, /etc/resolv.conf, and /etc/nsswitch.conf.

/etc/hostname

1. Edit /etc/hostname:
-422 mode
-485 2 wire mode
2. Re-configure the hostname.
3. Check the new hostname.

/etc/resolv.conf

This is the most important file that you need to edit when using DNS. For example, before using # ntpdate
time.stdtime.gov.tw to update the system time, you will need to add the DNS server address to the file. Ask
your network administrator which DNS server address you should use. The DNS server’s IP address is specified
with the nameserver command. For example, add the following line to /etc/resolv.conf (assuming the DNS
server’s IP address is 168.95.1.1):
V2416A Linux Managing Communications
3-5
root@MOXA:/etc# cat resolv.conf
MOXA:/etc#
# /etc/nsswitch.conf
netgroup: nis
#! /bin/bash
# Should-Start:
nameserver 168.95.1.1
#
# resolv.conf This file is the resolver configuration file
# See resolver(5).
#
#nameserver 192.168.1.16
nameserver 168.95.1.1
nameserver 140.115.1.31
nameserver 140.115.236.10

/etc/nsswitch.conf

This file defines the sequence of files, /etc/hosts or /etc/resolv.conf, to be read to resolve the IP address.
The hosts line in /etc/nsswitch.conf means use /etc/host first and DNS service to resolve the address.
#
# 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
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files

Configuring Ethernet Bonding

The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical
“bonded” interface. To use the bonding feature, load the bonding driver. Then use ifenslave to add the Ethernet
interface into the bond0 interface. The following script bonds eth1 and eth2 together; you can place the script
in /etc/init.d/bonding.
#### BEGIN INIT INFO
# Provides: bonding
# Short-Description: Start the bonding service, bond eth1 and eth2.
# Required-Start: $all
# Required-Stop: $all
Loading...
+ 58 hidden pages