Enabling nat at bootup, Dial-up service—ppp, Enabling nat at bootup -12 – Moxa Technologies THINKCORE W341 User Manual

Page 52: Dial-up service—ppp -12

Advertising
background image

ThinkCore W311/321/341 Linux User’s Manual

Managing Communications

4-12

Enabling NAT at Bootup

In most real world situations, you will want to use a simple shell script to enable NAT when the

W341 boots up. The following script is an example.

#!/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.d/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.

insmod ip_tables 2> /dev/null

insmod ip_conntrack 2> /dev/null

insmod ip_conntrack_ftp 2> /dev/null

insmod ip_conntrack_irc 2> /dev/null

insmod iptable_nat 2> /dev/null

insmod ip_nat_ftp 2> /dev/null

insmod ip_nat_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

/bin/iptables -F

/bin/iptables -X

/bin/iptables -Z

/bin/iptables -F -t nat

/bin/iptables -X -t nat

/bin/iptables -Z -t nat

/bin/iptables -P INPUT ACCEPT

/bin/iptables -P OUTPUT ACCEPT

/bin/iptables -P FORWARD ACCEPT

/bin/iptables -t nat -P PREROUTING ACCEPT

/bin/iptables -t nat -P POSTROUTING ACCEPT

/bin/iptables -t nat -P OUTPUT ACCEPT

# Step 3. Enable IP masquerade.

Dial-up Service—PPP

PPP (Point to Point Protocol) is used to run IP (Internet Protocol) and other network protocols over

a serial link. PPP can be used for direct serial connections (using a null-modem cable) over a

Telnet link, and links established using a modem over a telephone line.
Modem / PPP access is almost identical to connecting directly to a network through the

W311/321/341’s Ethernet port. Since PPP is a peer-to-peer system, the W311/321/341 can also

use PPP to link two networks (or a local network to the Internet) to create a Wide Area Network

(WAN).

NOTE

Click on the following links for more information about ppp:

http://tldp.org/HOWTO/PPP-HOWTO/index.html

http://axion.physics.ubc.ca/ppp-linux.html

The pppd daemon is used to connect to a PPP server from a Linux system. For detailed

information about pppd see the man page.

Example 1: Connecting to a PPP server over a simple dial-up connection

The following command is 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 password with the correct password). Note that debug and defaultroute 192.1.1.17 are

Advertising
This manual is related to the following products: