Close
The username and/or password are invalid. Please try again.

close
Go6
You are using IPv4 from 38.107.191.114
Free IPv6 Connection

We have moved! The go6 discussion forum has been locked down but will continue to be viewable.  The new discussion forum is on gogoNET at: http://gogonet.gogo6.com/forum 

NAT support for openbsd
Goto page 1, 2  Next
 
Post new topic   Reply to topic    go6 Forum Index -> Gateway6 Client on OpenBSD
View previous topic :: View next topic  
Author Message
insane



Joined: 12 Sep 2006
Posts: 1

PostPosted: Tue Dec 26, 2006 4:12 pm    Post subject: NAT support for openbsd Reply with quote

hello.

when i saw, that theres no NAT support in client for openbsd i was pretty shocked Shocked .

so... when we can expect that?


thanks for answer
Back to top
View user's profile Send private message Send e-mail
ahamelin
Go6 Staff


Joined: 10 Oct 2006
Posts: 54

PostPosted: Wed Jan 10, 2007 9:39 pm    Post subject: Reply with quote

insane,

The Gateway6 Client does not support NAT traversal. The reason is that OpenBSD does not properly support tunnel interfaces and therefore, UDP-in-IPv4 does not work. There is no due date so far as to when support will be added.
_________________
Alexandre Hamelin
Back to top
View user's profile Send private message
Kernigh
Go6 User


Joined: 01 Feb 2007
Posts: 16

PostPosted: Mon Feb 05, 2007 10:51 pm    Post subject: It works! Get the patch! Reply with quote

Hi insane and ahamelin,

I am using gw6c and NAT traversal from OpenBSD as of now. Recently I ported the relevant gw6c/FreeBSD code to OpenBSD. I am now accessing Freenet6 with IPv6-over-UDP-over-IPv4 using gw6c.

The patch is too big to fit here, but I uploaded it to http://kernigh.pbwiki.com/f/openbsdnat.patch

Code:

$ cd /where/is/tspc-advanced
$ patch -p1 < ../path/to/openbsdnat.patch

_________________
--Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kernigh
Go6 User


Joined: 01 Feb 2007
Posts: 16

PostPosted: Mon Feb 05, 2007 10:53 pm    Post subject: Reply with quote

Patch notes: The code added by my patch is a copy of Hexago's code for FreeBSD, plus some slight changes for OpenBSD.

  • OpenBSD tun(4) does not have TUNSIFHEAD/TUNSLMODE like FreeBSD tun(4). Instead it always behaves like TUNSIFHEAD. (Setting link0, which I never do, makes OpenBSD tun(4) behave like Linux/FreeBSD/NetBSD tap(4).) Also, setting TUNSDEBUG does not work (if_tun.h defines TUNSDEBUG but the manual page does not mention it). So I simply do not bother to set TUNSIFHEAD or TUNSLMODE in tsp_tun.c.

_________________
--Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kernigh
Go6 User


Joined: 01 Feb 2007
Posts: 16

PostPosted: Mon Feb 05, 2007 10:54 pm    Post subject: Reply with quote


  • Like FreeBSD, OpenBSD wants me to prepend four bytes with the address family. The FreeBSD code looked hard-coded to prepend an endian-swapped 28. I wanted an IPv6 tunnel, so I prepended AF_INET6 (defined in sys/socket.h, see socket(2)). I was careful to use htonl (see byteorder(3)) so that I would not wrongly endian-swap on my big-endian OpenBSD/macppc machine.
  • For some reason, openbsd.sh must Exec $ifconfig $TSP_TUNNEL_INTERFACE up or nothing works.

_________________
--Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kernigh
Go6 User


Joined: 01 Feb 2007
Posts: 16

PostPosted: Mon Feb 05, 2007 11:00 pm    Post subject: Reply with quote


  • I had a gcc warning from freadline() in tsp_auth_passdss.c. It is a bug to write (c=fgetc(fp)) != EOF) when c is a char because EOF is usually -1 but some compilers (like OpenBSD/macppc gcc) default char to unsigned. I fixed that bug.
  • In platform/openbsd/Makefile, it looks like I changed -lpthread to -pthread for no reason. I wanted to be consistent with intro(3), "Threaded applications should use -pthread not -lpthread."


End of patch notes.
_________________
--Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CoryCA
Go6 User


Joined: 27 Sep 2006
Posts: 20

PostPosted: Wed Feb 07, 2007 10:32 pm    Post subject: Re: It works! Get the patch! Reply with quote

Kernigh wrote:


Cool! Is this for 4.2.1 or 4.2.2?

I live in an older apartment with only 1 phone jack even though xDSL has been available for years. Thus I have the ADSL modem and a Linksys WRT54G in a cabinet by my door. Since you can't turn off the NAT stuff, the WRT54G is set to forward everything in DMZ mode to my OpenBSD machine. It's that or trip over a few meters of cat5 strung across my apartment to the computer desk. Razz

Because tspc2 requires that the world-visible IP address be in the config file (IIRC it's part of the request sent to the tunnel broker server), I had to come up with a hack that would both get my current dynamic address given by my ISP and fudge tspc2 to work with a 192/168/16 private address.

So one script in cron get my current IPv4 address from the WRT54G and writes it to a file, comparing what it was at the previous check 5 minutes ago. If it has changed it calls the following script:

Code:

#!/bin/sh
#
#
#tspc2.sh -
#

ip=`cat /var/www/html/myip.txt`
ifconfig gif0 destroy
sleep 2
tspc_conf=`sed "s/A\.B\.C\.D/$ip/" </root/tspc2/bin/auto-template.conf`
echo "$tspc_conf" >/root/tspc2/bin/auto.conf
pkill tspc
rm tspc.log
sleep 2
/root/tspc2/bin/tspc -vvvvv -f /root/tspc2/bin/auto.conf
r=$?
echo "result = $r"
if [ $r = 0 ]; then
        sleep 60
        ifconfig gif0 tunnel 192.168.16.1 64.86.88.116
fi


Basically, 1) destroy the old gif interface and kill the tspc process. 2) Update tspc config with current IPv4 address. 3) Run tspc to log in and set up the tunnel. Then, because the script ran by tspc for openbsd created gif0 with my end point as the IPv4 address allocated from my ISP, 4) destroy gif0 and recreate it with my 192.168/16 private address actually on the OpenBSD machine.

Since the NAT replaces my private address with the world-visible real IPv4 address, the tunnel broker doesn't appear to care. Its amazingly stable and rarely needs to be done unless ,y IPv4 address has changed and tat is teh same as if I weren't behind a NAT.

I look forward to trying your patch.
Back to top
View user's profile Send private message Send e-mail
Kernigh
Go6 User


Joined: 01 Feb 2007
Posts: 16

PostPosted: Sun Feb 11, 2007 8:01 pm    Post subject: Re: It works! Get the patch! Reply with quote

CoryCA wrote:
Cool! Is this for 4.2.1 or 4.2.2?


4.2.2

CoryCA wrote:
Since you can't turn off the NAT stuff, the WRT54G is set to forward everything in DMZ mode to my OpenBSD machine.


I am not able to change the configuration of my NAT, so I had to use UDP.

Currently, my connection breaks if I try to make a long post to this forum, and some downloads will stall. There might be a problem in my own patch or with my firewall connection. In pf.conf I do:

Code:

ext6_if="tun0"
icmp6_types="echoreq"
...
pass out keep state
pass in on $ext6_if inet6 proto icmp6 all icmp6-type $icmp6_types keep state
...


That is, I block all incomping ICMP6 connections except for pings, like I would for ICMP4. Because ICMP6 is different, maybe I did wrong.
_________________
--Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH
Back to top
View user's profile Send private message Send e-mail Visit poster's website
-openbsd-



Joined: 12 Sep 2006
Posts: 1

PostPosted: Fri Feb 23, 2007 2:45 am    Post subject: Re: It works! Get the patch! Reply with quote

Kernigh wrote:
Hi insane and ahamelin,

I am using gw6c and NAT traversal from OpenBSD as of now. Recently I ported the relevant gw6c/FreeBSD code to OpenBSD. I am now accessing Freenet6 with IPv6-over-UDP-over-IPv4 using gw6c.

The patch is too big to fit here, but I uploaded it to http://kernigh.pbwiki.com/f/openbsdnat.patch

Code:

$ cd /where/is/tspc-advanced
$ patch -p1 < ../path/to/openbsdnat.patch


Another way to do this is to just use IPv6 over IPv4. This has worked for me since the early tspc2 client several years ago. The trick is to set
client_v4=<public IP> in your conf file then put your private IP in template/openbsd.sh.

For example, replace line:

Exec $ifconfig $TSP_TUNNEL_INTERFACE giftunnel $TSP_CLIENT_ADDRESS_IPV4 $TSP_SERVER_ADDRESS_IPV4

with

Exec $ifconfig $TSP_TUNNEL_INTERFACE giftunnel <private IP> $TSP_SERVER_ADDRESS_IPV4

Perhaps the v6 over UDP over IPv4 method is just for dumb NAT devices that don't know how to NAT IPv6 over IPv4. Pf can do this just fine.
Back to top
View user's profile Send private message Send e-mail
tonyk



Joined: 27 Jan 2008
Posts: 3
Location: UK

PostPosted: Sun Feb 10, 2008 3:57 pm    Post subject: Reply with quote

hi kernigh
I have just been trying to get gw6c-5.1 to work with OpenBSD
4.2 GENERIC i386 but it seems unable to create the tunnel,
even with or without your patch. Although it says the link to
Go6.net is successful. Is there something I have to turn on
in the kernel.
My ifconfig just shows my link-local and IPv4 addresses.

Tony.
Back to top
View user's profile Send private message Send e-mail
brown1d



Joined: 12 Sep 2006
Posts: 1

PostPosted: Sat Mar 22, 2008 2:03 am    Post subject: Working on OpenBSD 4.2 with gw6c-5.1 Reply with quote

Tony,

I have this working, however the patch as it stands does not apply correctly, with the latest client code. In the end I found a pile of rejected code under platform/openbsd.

I have to manually patch Makefile and tsp_local.c.

With this done, I was able to establish a tunnel.

David
Back to top
View user's profile Send private message Send e-mail
tonyk



Joined: 27 Jan 2008
Posts: 3
Location: UK

PostPosted: Sat Mar 22, 2008 10:25 am    Post subject: Reply with quote

HI David.
Thanks for reply.
I will look into this again.

tony.
Back to top
View user's profile Send private message Send e-mail
cnepveu
Go6 Staff


Joined: 22 Sep 2006
Posts: 258
Location: Montréal, Québec

PostPosted: Tue Mar 25, 2008 3:21 pm    Post subject: Reply with quote

Hi there,

If you can send a working patch on 5.1 at ()support at go6.net(), I'll try to fit it in 5.2.
_________________
Charles Nepveu
Software Developer
Hexago, Inc.
support%go6.net
Back to top
View user's profile Send private message Send e-mail
debaser



Joined: 02 Apr 2008
Posts: 1

PostPosted: Sun Apr 06, 2008 10:30 pm    Post subject: Reply with quote

Here is an updated patch, almost all the work was done by
Kernigh http://wiki.go6.net/index.php?title=User:KERNIGH

Port: http://2d1g.net/files/OpenBSD-ports/gw6c.tar.gz
Package i386: http://2d1g.net/files/OpenBSD-ports/gw6c-5.1.tgz

I successfully tested it on macppc and i386 but it still needs much
work to get it ready for the official ports tree. Here is what I used
for a NATed connection.

/etc/gw6c.conf:
Code:

if_prefix=gem0
userid=USER
passwd=PASS
server=broker.freenet6.net
auth_method=any
host_type=router
prefixlen=48
dns_server=
gw6_dir=/usr/local/share/gw6c
auto_retry_connect=yes
retry_delay=30
keepalive=yes
keepalive_interval=30
tunnel_mode=v6udpv4
if_tunnel_v6udpv4=tun0
client_v4=auto
client_v6=auto
template=openbsd
proxy_client=no
broker_list=tsp-broker-list.txt
last_server=tsp-last-server.txt
always_use_same_server=no
log_filename=gw6c.log
log_rotation=yes
log_rotation_size=32
log_rotation_delete=no
syslog_facility=USER
Back to top
View user's profile Send private message Send e-mail
cnepveu
Go6 Staff


Joined: 22 Sep 2006
Posts: 258
Location: Montréal, Québec

PostPosted: Mon Apr 07, 2008 1:58 pm    Post subject: Reply with quote

Hello,

I have successfully integrated the patch in HEAD.
Version 5.2 of the Gateway6 client will UNOFFICIALLY support NAT traversal on OpenBSD.

Thank you Kernigh and all who have contributed to this.
_________________
Charles Nepveu
Software Developer
Hexago, Inc.
support%go6.net
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    go6 Forum Index -> Gateway6 Client on OpenBSD All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum