![]() | |||||||||
|
|
|
Assigning unique IP addresses for each serial port The simplest way to assign a unique IP address for each serial port is to run a script: #!/bin/sh # # This script is executed after all the other init scripts, and is where you # should put any customized startup items you require. # IP=192.168.0 IPSTART=100 # Set up the interfaces export PORTS=`cat /proc/tty/driver/serial | grep uart | \ grep -v "^48:" | cut -f1 -d":"` export PORTS=`for port in $PORTS;do echo $(($port+1));done` for port in $PORTS do ifconfig eth0:$port $IP.$(($port + $IPSTART)) netmask 255.255.255.0 up done # Accept port 22 connections only to the new interfaces iptables --new-chain Aliases iptables --append Aliases --match state --state ESTABLISHED,RELATED \ --jump ACCEPT for port in $PORTS do iptables --append Aliases --in-interface eth0 --protocol tcp \ --destination $IP.$(($port + $IPSTART)) \ --destination-port 22 --jump ACCEPT done # Redirect from eth0:x port 22 to eth0 port (3000+x) iptables --new-chain AliasNats -t nat for port in $PORTS do iptables --append AliasNats --table nat --in-interface eth0 --protocol tcp \ --destination $IP.$(($port + $IPSTART)) --dport 22 \ --jump DNAT --to :$(($port + 3000)) done iptables --append PREROUTING --table nat --protocol tcp --jump AliasNats Refer to faq 255 for more information on using scripts to customize your console server |
| © Opengear 2010| Privacy Policy |