<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ampr.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=4Z4ZQ</id>
	<title>44Net Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ampr.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=4Z4ZQ"/>
	<link rel="alternate" type="text/html" href="https://wiki.ampr.org/wiki/Special:Contributions/4Z4ZQ"/>
	<updated>2026-06-15T12:30:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=769</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=769"/>
		<updated>2018-06-06T06:02:40Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the 44/8 AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts  of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
 ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=768</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=768"/>
		<updated>2018-06-06T06:01:25Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the 44/8 AMPRNet please read the Portal page.&amp;quot; info on the main page )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts  of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
 ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=767</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=767"/>
		<updated>2018-06-06T05:58:16Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts  of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
 ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=759</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=759"/>
		<updated>2018-04-16T06:56:25Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: wrong amprgw adress fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
 ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=758</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=758"/>
		<updated>2018-04-16T06:54:04Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: AMPRGW AT UCSD  adress error&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
 ip route 169.228.33.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=723</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=723"/>
		<updated>2017-05-30T17:23:24Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Main router (the one that  you get the ISP  from it)  and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
Before you start  configure  the DMZ of your main router  at least to allow  two direction (Incoming/Outgoing) traffic to the InterNet   and make sure that the  wan  of the mikrotik router have ip on the same network  of your  DMZ  and check that the MikroTik Interface can communicate with the   Main ISP  router&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.34.84)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no  local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.34.84&lt;br /&gt;
&lt;br /&gt;
Make sure to check that  no keep alive is active on that  interface as the amprnet router dont like the keep alive data .&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.34.84/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.34.84/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=703</id>
		<title>RIP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=703"/>
		<updated>2017-05-24T16:30:13Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information about other AMPRNet [[gateway| gateways]] can now be received dynamically via modified [http://en.wikipedia.org/wiki/Routing_Information_Protocol RIPv2] advertisements. Previously, routes were obtained by creating a [[munge script]] that parsed [[Encap.txt]].&lt;br /&gt;
&lt;br /&gt;
= RIP44 Daemons =&lt;br /&gt;
&lt;br /&gt;
Two programs are available for GNU/Linux to utilize these updates:&lt;br /&gt;
&lt;br /&gt;
* [[ampr-ripd]], a C based routing daemon&lt;br /&gt;
* [[rip44d]], a PERL based routing daemon&lt;br /&gt;
&lt;br /&gt;
= Availability/Compatibility =&lt;br /&gt;
&lt;br /&gt;
The RIP44 daemons have been tested and known to work on the following operating systems:&lt;br /&gt;
&lt;br /&gt;
* BSD&lt;br /&gt;
* OpenWRT/LEDE&lt;br /&gt;
* Raspbian&lt;br /&gt;
* Slackware Linux&lt;br /&gt;
* Ubuntu/Debian Linux&lt;br /&gt;
* Vyatta/VyOS&lt;br /&gt;
&lt;br /&gt;
= Non-RIP44 Workarounds =&lt;br /&gt;
&lt;br /&gt;
The devices below do not possess a known, end-user method to install additional software (i.e. ampr-ripd). Operators have developed scripts to parse inbound routing packets to make them compatible for usage on AMPRNet:&lt;br /&gt;
&lt;br /&gt;
* Cisco IOS (a separate machine must run the script) : look here http://wiki.ampr.org/wiki/Setting_up_a_gateway_on_Cisco_Routers  at the &amp;quot;Making the route commands automatically&amp;quot; section&lt;br /&gt;
* JunOS&lt;br /&gt;
* MikroTik : look here  http://www.yo2loj.ro/hamprojects/ at the &amp;quot;Mikrotik RIPv2 AMPR Gateway Setup Script 3.0&amp;quot;&lt;br /&gt;
* Ubiquiti OS&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[startampr]] - a script that loads the routing daemon on boot on Linux server-type devices&lt;br /&gt;
* Instructions for [[setting up a gateway on Linux|setting up a tunnel gateway on Linux]]&lt;br /&gt;
* Instructions for [[setting up a gateway on OpenWRT|setting up a gateway on OpenWRT]]&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=702</id>
		<title>RIP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=702"/>
		<updated>2017-05-24T16:29:36Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information about other AMPRNet [[gateway| gateways]] can now be received dynamically via modified [http://en.wikipedia.org/wiki/Routing_Information_Protocol RIPv2] advertisements. Previously, routes were obtained by creating a [[munge script]] that parsed [[Encap.txt]].&lt;br /&gt;
&lt;br /&gt;
= RIP44 Daemons =&lt;br /&gt;
&lt;br /&gt;
Two programs are available for GNU/Linux to utilize these updates:&lt;br /&gt;
&lt;br /&gt;
* [[ampr-ripd]], a C based routing daemon&lt;br /&gt;
* [[rip44d]], a PERL based routing daemon&lt;br /&gt;
&lt;br /&gt;
= Availability/Compatibility =&lt;br /&gt;
&lt;br /&gt;
The RIP44 daemons have been tested and known to work on the following operating systems:&lt;br /&gt;
&lt;br /&gt;
* BSD&lt;br /&gt;
* OpenWRT/LEDE&lt;br /&gt;
* Raspbian&lt;br /&gt;
* Slackware Linux&lt;br /&gt;
* Ubuntu/Debian Linux&lt;br /&gt;
* Vyatta/VyOS&lt;br /&gt;
&lt;br /&gt;
= Non-RIP44 Workarounds =&lt;br /&gt;
&lt;br /&gt;
The devices below do not possess a known, end-user method to install additional software (i.e. ampr-ripd). Operators have developed scripts to parse inbound routing packets to make them compatible for usage on AMPRNet:&lt;br /&gt;
&lt;br /&gt;
* Cisco IOS (a separate machine must run the script) : look here http://wiki.ampr.org/wiki/Setting_up_a_gateway_on_Cisco_Routers  at the &amp;quot;Making the route commands automatically&amp;quot; section&amp;quot;&lt;br /&gt;
* JunOS&lt;br /&gt;
* MikroTik : look here  http://www.yo2loj.ro/hamprojects/ at the &amp;quot;Mikrotik RIPv2 AMPR Gateway Setup Script 3.0&amp;quot;&lt;br /&gt;
* Ubiquiti OS&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[startampr]] - a script that loads the routing daemon on boot on Linux server-type devices&lt;br /&gt;
* Instructions for [[setting up a gateway on Linux|setting up a tunnel gateway on Linux]]&lt;br /&gt;
* Instructions for [[setting up a gateway on OpenWRT|setting up a gateway on OpenWRT]]&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=701</id>
		<title>RIP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=701"/>
		<updated>2017-05-24T16:21:12Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information about other AMPRNet [[gateway| gateways]] can now be received dynamically via modified [http://en.wikipedia.org/wiki/Routing_Information_Protocol RIPv2] advertisements. Previously, routes were obtained by creating a [[munge script]] that parsed [[Encap.txt]].&lt;br /&gt;
&lt;br /&gt;
= RIP44 Daemons =&lt;br /&gt;
&lt;br /&gt;
Two programs are available for GNU/Linux to utilize these updates:&lt;br /&gt;
&lt;br /&gt;
* [[ampr-ripd]], a C based routing daemon&lt;br /&gt;
* [[rip44d]], a PERL based routing daemon&lt;br /&gt;
&lt;br /&gt;
= Availability/Compatibility =&lt;br /&gt;
&lt;br /&gt;
The RIP44 daemons have been tested and known to work on the following operating systems:&lt;br /&gt;
&lt;br /&gt;
* BSD&lt;br /&gt;
* OpenWRT/LEDE&lt;br /&gt;
* Raspbian&lt;br /&gt;
* Slackware Linux&lt;br /&gt;
* Ubuntu/Debian Linux&lt;br /&gt;
* Vyatta/VyOS&lt;br /&gt;
&lt;br /&gt;
= Non-RIP44 Workarounds =&lt;br /&gt;
&lt;br /&gt;
The devices below do not possess a known, end-user method to install additional software (i.e. ampr-ripd). Operators have developed scripts to parse inbound routing packets to make them compatible for usage on AMPRNet:&lt;br /&gt;
&lt;br /&gt;
* Cisco IOS (a separate machine must run the script)&lt;br /&gt;
* JunOS&lt;br /&gt;
* MikroTik : look here  http://www.yo2loj.ro/hamprojects/ at the &amp;quot;Mikrotik RIPv2 AMPR Gateway Setup Script 3.0&amp;quot;&lt;br /&gt;
* Ubiquiti OS&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[startampr]] - a script that loads the routing daemon on boot on Linux server-type devices&lt;br /&gt;
* Instructions for [[setting up a gateway on Linux|setting up a tunnel gateway on Linux]]&lt;br /&gt;
* Instructions for [[setting up a gateway on OpenWRT|setting up a gateway on OpenWRT]]&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=700</id>
		<title>RIP</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=RIP&amp;diff=700"/>
		<updated>2017-05-24T16:19:15Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information about other AMPRNet [[gateway| gateways]] can now be received dynamically via modified [http://en.wikipedia.org/wiki/Routing_Information_Protocol RIPv2] advertisements. Previously, routes were obtained by creating a [[munge script]] that parsed [[Encap.txt]].&lt;br /&gt;
&lt;br /&gt;
= RIP44 Daemons =&lt;br /&gt;
&lt;br /&gt;
Two programs are available for GNU/Linux to utilize these updates:&lt;br /&gt;
&lt;br /&gt;
* [[ampr-ripd]], a C based routing daemon&lt;br /&gt;
* [[rip44d]], a PERL based routing daemon&lt;br /&gt;
&lt;br /&gt;
= Availability/Compatibility =&lt;br /&gt;
&lt;br /&gt;
The RIP44 daemons have been tested and known to work on the following operating systems:&lt;br /&gt;
&lt;br /&gt;
* BSD&lt;br /&gt;
* OpenWRT/LEDE&lt;br /&gt;
* Raspbian&lt;br /&gt;
* Slackware Linux&lt;br /&gt;
* Ubuntu/Debian Linux&lt;br /&gt;
* Vyatta/VyOS&lt;br /&gt;
&lt;br /&gt;
= Non-RIP44 Workarounds =&lt;br /&gt;
&lt;br /&gt;
The devices below do not possess a known, end-user method to install additional software (i.e. ampr-ripd). Operators have developed scripts to parse inbound routing packets to make them compatible for usage on AMPRNet:&lt;br /&gt;
&lt;br /&gt;
* Cisco IOS (a separate machine must run the script)&lt;br /&gt;
* JunOS&lt;br /&gt;
* MikroTik  look here  http://www.yo2loj.ro/hamprojects/ at the &amp;quot;Mikrotik RIPv2 AMPR Gateway Setup Script 3.0&amp;quot;&lt;br /&gt;
* Ubiquiti OS&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[startampr]] - a script that loads the routing daemon on boot on Linux server-type devices&lt;br /&gt;
* Instructions for [[setting up a gateway on Linux|setting up a tunnel gateway on Linux]]&lt;br /&gt;
* Instructions for [[setting up a gateway on OpenWRT|setting up a gateway on OpenWRT]]&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=697</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=697"/>
		<updated>2017-05-15T17:38:21Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Main router (the one that  you get the ISP  from it)  and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
Before you start  configure  the DMZ of your main router  at least to allow  two direction (Incoming/Outgoing) traffic to the InterNet   and make sure that the  wan  of the mikrotik router have ip on the same network  of your  DMZ  and check that the MikroTik Interface can communicate with the   Main ISP  router&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=696</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=696"/>
		<updated>2017-05-15T17:26:46Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Main router (the one that  you get the ISP  from it)  and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
Before you start  configure  the DMZ of your main router  at least to allow  two way trafic to the   UCSD Router and make sure that the  wan  of the mikrotik router have ip on the same network  of your  DMZ  and check that the MikroTik Interface can communicate with the   Main ISP  router&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=695</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=695"/>
		<updated>2017-05-15T17:20:01Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Main router (the one that  you get the ISP  from it)  and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=694</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=694"/>
		<updated>2017-05-15T17:18:45Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=693</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=693"/>
		<updated>2017-05-15T17:18:21Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To setup a Gateway  you need to have  mikrotik router (all models support IPIP  by default)&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel , &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=688</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=688"/>
		<updated>2017-04-22T17:56:08Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface have to  be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Fill in the local address field your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address fill the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=687</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=687"/>
		<updated>2017-04-22T17:52:42Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
You do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for , there is a drop down menu that show all of your interfaces  , chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface must be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway , type the ip address of the next router (for home network  , it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=686</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=686"/>
		<updated>2017-04-22T17:44:43Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
you do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New , a new screen will open , fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should usually be same as the IP but with 0 in the end &lt;br /&gt;
&lt;br /&gt;
Now chose which interface you assign this IP for  there is a drop down menu that show all of your interfaces chose the one that connected to the local net &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface must be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  Add New --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
Add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
At the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=685</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=685"/>
		<updated>2017-04-22T17:40:42Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
you do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New  a new screen will open  fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should useually be same as the IP but with 0 in the end &lt;br /&gt;
now chose which interface you assign this IP for  there is a drop down menu that show all of your interfaces &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface must be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=684</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=684"/>
		<updated>2017-04-22T17:39:38Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
At first  assign 44 Net address to your router Interface &lt;br /&gt;
you do it by the web  : IP --&amp;gt; Addresses  --&amp;gt; Add New  a new screen will open  fill your 44 Net IP  44.xxx.YYY.ZZZ/your sub net (usually it will be /24) &lt;br /&gt;
feel the network it should useually be same as the IP but with 0 in the end &lt;br /&gt;
now chose which interface you assign this IP for  there is a drop down menu that show all of your interfaces &lt;br /&gt;
&lt;br /&gt;
Now a tunnel interface must be created  between your router and  the main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=683</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=683"/>
		<updated>2017-04-02T18:44:47Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=682</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=682"/>
		<updated>2017-04-02T18:31:52Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 AMPRNet IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=574</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=574"/>
		<updated>2016-05-27T09:41:19Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface ethernet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router type , it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card any additional network IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Gateway&amp;diff=566</id>
		<title>Gateway</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Gateway&amp;diff=566"/>
		<updated>2016-04-14T20:51:22Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A lot of the 44/8 address space is interconnected via [[gateway|gateways]]. These are IPIP encapsulated [[tunnel|tunnels]] that carry the 44/8 address space allocated to a particular region or end user. There exists a database of all the gateways public IP addresses and the subnets they service on the [[portal]]. This database is used to dynamically generate gateway information via modified [[RIP]] advertisements. This database also generates a file called [[encap.txt]] which is basically a routing table that specifies which subnets can be reached via which gateway. &lt;br /&gt;
&lt;br /&gt;
Learn how to [[Setting up a gateway on Linux|setup a Linux gateway]]&lt;br /&gt;
&lt;br /&gt;
Learn how to [[Setting up a gateway on OpenWRT|setup an OpenWRT gateway]]&lt;br /&gt;
&lt;br /&gt;
Learn how to [[Setting up a gateway on Cisco Routers|setup a  Cisco Router gateway]]&lt;br /&gt;
&lt;br /&gt;
Learn how to [[setting up a gateway on MikroTik Routers|setting up a  gateway on MikroTik Routers]]&lt;br /&gt;
&lt;br /&gt;
In order to keep this database up to date, everyone that operates a gateway must register on the [[portal]] and have their gateway assigned to their account.&lt;br /&gt;
&lt;br /&gt;
As the portal only went live recently, we are in a transition phase, where all the old gateway entries that existed have been copied into the new database and are awaiting their &amp;quot;owners&amp;quot; to claim them. After a suitable period of time has elapsed, about a year, any unclaimed gateways will be removed from the system, thus ensuring that the database is as up to date and as accurate as possible. It is therefore important to register and claim your gateway asap!&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=565</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=565"/>
		<updated>2016-04-13T06:21:51Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;br /&gt;
&lt;br /&gt;
The MikroTik  have ability to run an automatic script  that deal  with the routing to the rest of the  AMPRNET  networks&lt;br /&gt;
&lt;br /&gt;
The script  run inside the router and take care  of all  the routes  &lt;br /&gt;
&lt;br /&gt;
In general  it listen to the routes advertisements send from the  AMPR.ORG  main router  and translating it to  routes commands to the router &lt;br /&gt;
&lt;br /&gt;
The Script can be found here  http://www.yo2loj.ro/hamprojects/ampr-gw-2.0.rsc&lt;br /&gt;
&lt;br /&gt;
The Commands to  run it can be found  here   http://www.yo2loj.ro/hamprojects/ampr-gw-README.txt&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=564</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=564"/>
		<updated>2016-04-11T11:21:17Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  by default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will show the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (wan and lan Referring to  a home router model)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNet router &lt;br /&gt;
&lt;br /&gt;
You do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=563</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=563"/>
		<updated>2016-04-11T11:01:12Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will deal with the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (Referring to  a home router)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNET router &lt;br /&gt;
&lt;br /&gt;
you do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
The command line  in text  is as follow&lt;br /&gt;
&lt;br /&gt;
  /ip route&lt;br /&gt;
 add distance=1 gateway=UCSD&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
The command line  is as follows &lt;br /&gt;
&lt;br /&gt;
 /ip route&lt;br /&gt;
 add distance=1 dst-address=169.228.66.251/32 gateway=10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=562</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=562"/>
		<updated>2016-04-11T10:55:18Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will deal with the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (Referring to  a home router)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNET router &lt;br /&gt;
&lt;br /&gt;
you do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
The  Command in  command line interface (via Telnet  ot SSH)  is as follows&lt;br /&gt;
 &lt;br /&gt;
 /interface ipip&lt;br /&gt;
 add allow-fast-path=no !keepalive local-address=10.0.0.180 name=UCSD \&lt;br /&gt;
    remote-address=169.228.66.251&lt;br /&gt;
&lt;br /&gt;
Now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=561</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=561"/>
		<updated>2016-04-10T21:44:39Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will deal with the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will appear on the Lan Port  (Referring to  a home router)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNET router &lt;br /&gt;
&lt;br /&gt;
you do it in the web by this : interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the address of the AMPRNET router (169.228.66.251)&lt;br /&gt;
&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the traffic to the tunnel interface&lt;br /&gt;
&lt;br /&gt;
You do it by : IP --&amp;gt; Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---&amp;gt; routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen , type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=560</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=560"/>
		<updated>2016-04-10T21:39:24Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
&lt;br /&gt;
The example here will deal with the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will apear on the Lan Port  (Refering to  a home router)&lt;br /&gt;
&lt;br /&gt;
The configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNET router &lt;br /&gt;
you do it in the web by this  interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
&lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
&lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
&lt;br /&gt;
at the remote address put the adress of the AMPRNET router (169.228.66.251)&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
now some routes commands needed to be done &lt;br /&gt;
&lt;br /&gt;
1) Route all the trafic to the tunnel interface&lt;br /&gt;
You do it by  IP--&amp;gt;Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
&lt;br /&gt;
You do it by the web  as follows :  IP  ---? routes ---&amp;gt;  add new&lt;br /&gt;
&lt;br /&gt;
at the screen type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
&lt;br /&gt;
Now you should have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide )&lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=559</id>
		<title>Setting up a gateway on MikroTik Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_MikroTik_Routers&amp;diff=559"/>
		<updated>2016-04-10T21:37:10Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: Created page with &amp;quot;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy The mikrotik router is a very powerful device and there are a lot of option...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The MikroTik Routers  By default  support  IP-IP  tunneling  so setting  up a gateway is quiet easy&lt;br /&gt;
The mikrotik router is a very powerful device and there are a lot of options that can be used &lt;br /&gt;
The example here will deal with the router that  the WAN Port  is connected to the DMZ   of your Network and the 44 Net will apear on the Lan Port  (Refering to  a home router)&lt;br /&gt;
&lt;br /&gt;
the configuration can be done with the web interface (webFig)  or in manual text command with telnet or SSH   connection to the router&lt;br /&gt;
&lt;br /&gt;
First a tunnel interface must be created  to the Main  AMPRNET router &lt;br /&gt;
you do it in the web by this  interfaces ---&amp;gt;  add new --&amp;gt; IP  tunnel &lt;br /&gt;
a Screen will open &lt;br /&gt;
Change the name to say  UCSD &lt;br /&gt;
add in the local address your router address on the DMZ (in home it will probably be 10.0.0.x or 192.168.1.x)&lt;br /&gt;
at the remote address put the adress of the AMPRNET router (169.228.66.251)&lt;br /&gt;
Press the apply button and you are done&lt;br /&gt;
&lt;br /&gt;
now some routes commands needed to be done &lt;br /&gt;
1) Route all the trafic to the tunnel interface&lt;br /&gt;
You do it by  IP--&amp;gt;Routes  and clicking on the 0.0.0.0  line&lt;br /&gt;
and changing the gateway  to the tunnel interface name and clicking apply&lt;br /&gt;
2) route command for the tunnel to go to the InterNet&lt;br /&gt;
You do it by the web  as follows :  IP  ---? routes ---&amp;gt;  add new&lt;br /&gt;
at the screen type in the destination address 169.228.66.251/32 &lt;br /&gt;
and at the gateway type the ip address of the next router (for home network it is usually  10.0.0.138  or 192.168.1.1)&lt;br /&gt;
Now you shoul have connectivity from your  44 Net  to the rest of the world (but not to any other 44 net  networks worldwide &lt;br /&gt;
&lt;br /&gt;
In  order  to have a full connectivity to the other 44 Net  networks   a tunnel  (and corresponding  route command) must be added  for every 44 Net gateway&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Archive/Main_Page&amp;diff=558</id>
		<title>Archive/Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Archive/Main_Page&amp;diff=558"/>
		<updated>2016-04-10T21:10:28Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the AMPRNet Wiki.&lt;br /&gt;
&lt;br /&gt;
Since its allocation to Amateur Radio in the mid-1980&#039;s, Internet network 44 (44.0.0.0/8), known as the AMPRNet™, has been used by amateur radio operators to conduct scientific research and to experiment with digital communications over radio with a goal of advancing the state of the art of Amateur Radio networking, and to educate amateur radio operators in these techniques. - [http://www.ampr.org/ www.ampr.org]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
== Starting points ==&lt;br /&gt;
* Basic information about the [[AMPRNet]] and the [[ampr.org]] domain&lt;br /&gt;
* [[Services]] available on AMPRNet&lt;br /&gt;
* If you are looking to get an IP allocation within the 44/8 AMPRNet please read the [[Portal]] page.&lt;br /&gt;
&lt;br /&gt;
== How to connect to AMPRNet ==&lt;br /&gt;
&lt;br /&gt;
* Instructions for [[Setting up a gateway on Linux|setup a Linux gateway]]&lt;br /&gt;
* Instructions for [[setting up a gateway on Cisco Routers|setting up a  gateway on Cisco Routers]].&lt;br /&gt;
* Instructions for [[setting up a gateway on MikroTik Routers|setting up a  gateway on MikroTik Routers]].&lt;br /&gt;
* Instructions for [[setting up a gateway on OpenWRT|setting up a gateway on OpenWRT]].&lt;br /&gt;
* Instructions for [[announcing your allocation directly|directly announcing your allocation via your Internet Service Provider (ISP)]].&lt;br /&gt;
* Instructions for [[AMPRNet VPN|Accessing AMPRNet via VPN]] (experimental).&lt;br /&gt;
* &amp;lt;b&amp;gt;[[Why can&#039;t I just route my AMPRNet allocation directly myself ?]]&amp;lt;/b&amp;gt;&lt;br /&gt;
* If you already operate a [[gateway]] please ensure you have registered on the [[portal]] and &amp;quot;claimed&amp;quot; your [[gateway]].&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
To keep up-to-date on AMPRNet information please consider joining the [[44Net mailing list]].&lt;br /&gt;
&lt;br /&gt;
== Contribute! ==&lt;br /&gt;
If you wish to contribute to the wiki, please send an email to &amp;lt;tt&amp;gt;wiki (at) ampr.org&amp;lt;/tt&amp;gt; introducing yourself. Please specify your full name, amateur radio callsign and your preferred username. A login will then be created for you.&lt;br /&gt;
&lt;br /&gt;
== Terms of Service ==&lt;br /&gt;
Use of 44.0.0.0/8 address space and ampr.org DNS is governed by the following [http://www.ampr.org/tos.txt Terms of Service]&lt;br /&gt;
&lt;br /&gt;
== All Pages ==&lt;br /&gt;
[http://wiki.ampr.org/wiki/Special:AllPages Here&#039;s a list of all pages currently on the AMPRNet Wiki]&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=552</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=552"/>
		<updated>2016-03-10T09:33:17Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router type , it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card any additional network IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=551</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=551"/>
		<updated>2016-03-10T09:29:38Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card any additional network IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=550</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=550"/>
		<updated>2016-03-09T14:24:28Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card the IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notifyed to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=549</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=549"/>
		<updated>2016-03-09T14:23:05Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card the IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notifyed to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and not 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=548</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=548"/>
		<updated>2016-03-09T14:17:31Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card the IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notifyed to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and not 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=547</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=547"/>
		<updated>2016-03-08T19:27:05Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card the IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and not 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  (excluding  the  44 net)  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=546</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=546"/>
		<updated>2016-03-08T19:11:18Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 interface etherbet0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depend on your router  it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc  &lt;br /&gt;
&lt;br /&gt;
To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet  card name&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
For router with one card the IP has to  be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel)&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and not 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses  BESIDE the  44 net  that  needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=545</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=545"/>
		<updated>2016-03-06T22:54:33Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and Tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=544</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=544"/>
		<updated>2016-03-06T22:52:15Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and Tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=543</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=543"/>
		<updated>2016-03-06T22:51:14Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and Tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
 Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=542</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=542"/>
		<updated>2016-03-02T19:54:24Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and Tunnel destination (to where the tunnel establish to)  &lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=541</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=541"/>
		<updated>2016-03-02T19:51:00Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=540</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=540"/>
		<updated>2016-03-02T19:49:53Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with one ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=539</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=539"/>
		<updated>2016-03-02T19:48:40Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To set a getway with Cisco you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
The example given here  here is of one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with 0ne ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=538</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=538"/>
		<updated>2016-03-02T11:00:09Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You  can setup gateway on  Cisco routers&lt;br /&gt;
&lt;br /&gt;
Cisco  support   IPIP  tunneling and that&#039;s what needed&lt;br /&gt;
&lt;br /&gt;
First of all you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
I  will give example of  one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with 0ne ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=537</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=537"/>
		<updated>2016-03-02T10:53:48Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: Undo revision 536 by 4Z4ZQ (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You  can setup gateway on  Cisco routers&lt;br /&gt;
&lt;br /&gt;
Cisco  support   IPIP  tunneling and that&#039;s what needed&lt;br /&gt;
&lt;br /&gt;
First of all you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
I  will give example of  one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with 0ne ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; #!/usr/bin/perl&lt;br /&gt;
#encapconvert.pl V0.1 10-31-12&lt;br /&gt;
#Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
#This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
#into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
#this on a 2600 or better router due to interface limits.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
my ($line);&lt;br /&gt;
my %nets = ();&lt;br /&gt;
my $net = undef;&lt;br /&gt;
my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
#####&lt;br /&gt;
#Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
#EO user defined varibles&lt;br /&gt;
#####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my $file = $ARGV[0];&lt;br /&gt;
my $debug = $ARGV[1];&lt;br /&gt;
if(!$file) { usage(); exit; } &lt;br /&gt;
if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
open(ENCAP, $file);&lt;br /&gt;
@line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
close (ENCAP);&lt;br /&gt;
@line = grep (!/^\s*$/,@line);&lt;br /&gt;
@line = grep (!/^#/,@line);&lt;br /&gt;
chomp(@line);&lt;br /&gt;
&lt;br /&gt;
foreach $line(@line)&lt;br /&gt;
{&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
*** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
*** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
*** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
*** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
*** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
*** Run as follows:                                                                 ***&lt;br /&gt;
*** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
########################################################&lt;br /&gt;
# Sub cipdec&lt;br /&gt;
# USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
#&lt;br /&gt;
# my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
# if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
#&lt;br /&gt;
sub cipdec&lt;br /&gt;
  {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
### wildcard sub ###&lt;br /&gt;
sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=536</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=536"/>
		<updated>2016-03-02T10:53:07Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You  can setup gateway on  Cisco routers&lt;br /&gt;
&lt;br /&gt;
Cisco  support   IPIP  tunneling and that&#039;s what needed&lt;br /&gt;
&lt;br /&gt;
First of all you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
I  will give example of  one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with 0ne ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/usr/bin/perl&lt;br /&gt;
#encapconvert.pl V0.1 10-31-12&lt;br /&gt;
#Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
#This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
#into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
#this on a 2600 or better router due to interface limits.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
my ($line);&lt;br /&gt;
my %nets = ();&lt;br /&gt;
my $net = undef;&lt;br /&gt;
my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
#####&lt;br /&gt;
#Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
#EO user defined varibles&lt;br /&gt;
#####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my $file = $ARGV[0];&lt;br /&gt;
my $debug = $ARGV[1];&lt;br /&gt;
if(!$file) { usage(); exit; } &lt;br /&gt;
if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
open(ENCAP, $file);&lt;br /&gt;
@line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
close (ENCAP);&lt;br /&gt;
@line = grep (!/^\s*$/,@line);&lt;br /&gt;
@line = grep (!/^#/,@line);&lt;br /&gt;
chomp(@line);&lt;br /&gt;
&lt;br /&gt;
foreach $line(@line)&lt;br /&gt;
{&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
*** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
*** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
*** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
*** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
*** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
*** Run as follows:                                                                 ***&lt;br /&gt;
*** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
########################################################&lt;br /&gt;
# Sub cipdec&lt;br /&gt;
# USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
#&lt;br /&gt;
# my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
# if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
#&lt;br /&gt;
sub cipdec&lt;br /&gt;
  {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
### wildcard sub ###&lt;br /&gt;
sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
### EO wildcard sub ### &lt;br /&gt;
&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=535</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=535"/>
		<updated>2016-03-02T10:51:16Z</updated>

		<summary type="html">&lt;p&gt;4Z4ZQ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You  can setup gateway on  Cisco routers&lt;br /&gt;
&lt;br /&gt;
Cisco  support   IPIP  tunneling and that&#039;s what needed&lt;br /&gt;
&lt;br /&gt;
First of all you must have a Cisco Router  (preferred from  series 2600  and  above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two  Ethernet cards (but can be done also with one Ethernet card)&lt;br /&gt;
&lt;br /&gt;
I  will give example of  one Ethernet card &lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet card the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The command is :&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;and here you give the ip of the commercial ip the router sit on &amp;gt;&lt;br /&gt;
 (it can be also IP of a network the router sit on  (as long as  this IP is accessible &lt;br /&gt;
 to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the 44 Net IP  &lt;br /&gt;
&lt;br /&gt;
The command for  router with 0ne ethernet card is:&lt;br /&gt;
&lt;br /&gt;
 int eth0  ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now you have to add some  tunneling command to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of his network  (and 44 net is not belong to any  ISP) so in order to allow the 44 Net Packet to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG Router  also to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the  44 NET))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel command you have to put the tunnel Source address (from where the tunnel is established) and to where the tunnel establish to  (tunnel destination)&lt;br /&gt;
it is a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip   (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition you must tell  the router to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connecting to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0  mean &amp;quot;everything&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to let the traffic from the router  to the main ampr.org router to pass their IP not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;everything&amp;quot; route command  described before and say to the router  pass the traffic  belong to the other side of the tunnel&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This  are the minimum  Commands to be able to route your  inside 44  Net ip to the outside world (but not to any  other 44 net  networks worldwide)&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 interface Tunnel0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source Ethernet0&lt;br /&gt;
 tunnel destination 169.228.66.251&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 interface Tunnel741916672&lt;br /&gt;
 description Link to 44.56.192.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 24.229.88.253&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
 interface Ethernet0&lt;br /&gt;
 description connected to EthernetLAN_HAIFA&lt;br /&gt;
 ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
 ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
 no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
 ip classless&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.66.251&lt;br /&gt;
 ip route 169.228.66.251 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
 ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
&lt;br /&gt;
Making the roue  commands  automaticly&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because alot of gateway sit on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available  one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; #!/usr/bin/perl&lt;br /&gt;
#encapconvert.pl V0.1 10-31-12&lt;br /&gt;
#Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
#This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
#into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
#this on a 2600 or better router due to interface limits.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
my ($line);&lt;br /&gt;
my %nets = ();&lt;br /&gt;
my $net = undef;&lt;br /&gt;
my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
#####&lt;br /&gt;
#Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
#EO user defined varibles&lt;br /&gt;
#####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my $file = $ARGV[0];&lt;br /&gt;
my $debug = $ARGV[1];&lt;br /&gt;
if(!$file) { usage(); exit; } &lt;br /&gt;
if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
open(ENCAP, $file);&lt;br /&gt;
@line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
close (ENCAP);&lt;br /&gt;
@line = grep (!/^\s*$/,@line);&lt;br /&gt;
@line = grep (!/^#/,@line);&lt;br /&gt;
chomp(@line);&lt;br /&gt;
&lt;br /&gt;
foreach $line(@line)&lt;br /&gt;
{&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
*** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
*** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
*** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
*** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
*** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
*** Run as follows:                                                                 ***&lt;br /&gt;
*** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
########################################################&lt;br /&gt;
# Sub cipdec&lt;br /&gt;
# USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
#&lt;br /&gt;
# my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
# if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
#&lt;br /&gt;
sub cipdec&lt;br /&gt;
  {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
### wildcard sub ###&lt;br /&gt;
sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>4Z4ZQ</name></author>
	</entry>
</feed>