Ga naar inhoud


Port forwarding in ubuntu 11.04


mr|repel

Aanbevolen berichten

Hoi allemaal,

 

Ik heb hier een IP cam die streamt op poort 80 (http stream) en wil deze graag ook buiten mijn eigen netwerk zien. Als server voor internet ( en vele andere dingen) heb ik een ubuntu desktop 11.04 pc draaien met een 3G usb stick voor internet (ppp0) en een interne netwerk kaart (eth0).

 

Al 3 dagen ben ik bezig om poort 8080 door te knopen naar mijn interne netwerk 10.42.43.65 poort 80

 

internet xxx.xxx.xxx.xxx:8080-----> ppp0 ( UBUNTU ) eth0 --------> 10.42.43.65:80

 

Vanalles heb ik al geprobeerd, firestarter, gufw, webmin, iptables etc maar ik blijf vast lopen. Het forwarden wil maar niet lukken. Ik ben "gewoon" te zien op het net en mijn andere services kan ik wel extern op inloggen.

 

Wie o wie heeft wat meer kaas hiervan gegeten en kan mij helpen ?

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites


  • Moderator

zoiets zou het moeten zijn met iptables:

 

iptables -A PREROUTING -d <WANIP> -j VSERVER
iptables -A POSTROUTING -s ! <WANIP> -o eth0 -j MASQUERADE
iptables -A POSTROUTING -s <LAN-IPNET/NETMASK> -d <LAN-IPNET/NETMASK> -o eth0 -j MASQUERADE
iptables -A VSERVER -p tcp -m tcp --dport 8080 -j DNAT --to-destination 10.42.43.65:80

VU+ Duo2  met VTi  13 VU+ Uno met VTi  9.0.2

geen Canal Digitaal meer en geen Sparql iptv meer
Triax 78, astra 1,2,3, HB

Link naar reactie
Delen op andere sites

Hoi Wiz, bedankt voor je reactie. Ik doe voor de rest niet veel routen in het netwerk, het internet delen staat aan en dat was het eigenlijk, iedereen krijgt een adresje van de dhcp en klaar. het probleem is in deze dat ik een dynamisch IP adres heb op ppp0 en deze niet kan vastzetten.

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites

  • Moderator

ah, dat maakt het al wat ingewikkelder. Je zou in theorie bovenstaande wel kunnen gebruiken, maar dan zul je zodra de ppp interface up is het ip adres moeten achterhalen en dan invoegen in de iptables commando's zoals boven staan.

 

Als het goed is staat er in /etc/network het een en ander wat scripts kan uitvoeren zodra een interface up is. Het is voor mij al weer een hele tijd geleden dat ik met ppp in de weer geweest ben (toen ik nog isdn had :) ). Op het internet moet vast wel een en ander te vinden zijn hoe je het wan ip adres kan achterhalen en hoe je dat dan kan invoegen in een scriptje wat als je ppp interface up is dit verwerkt in de iptables.

 

 

je kan dit nog proberen:

 

iptables -A PREROUTING -d ppp0 -j VSERVER
iptables -t nat -A POSTROUTING -s <lanip/netmask> -o ppp0 -j MASQUERADE
iptables -A VSERVER -p tcp -m tcp --dport 8080 -j DNAT --to-destination 10.42.43.65:80 

 

Ik heb nog even in google gezocht, maar er is verbazingwekkend weinig meer van te vinden.

VU+ Duo2  met VTi  13 VU+ Uno met VTi  9.0.2

geen Canal Digitaal meer en geen Sparql iptv meer
Triax 78, astra 1,2,3, HB

Link naar reactie
Delen op andere sites

En alweer bedankt voor de reactie. Ik ga eens wat proberen. Bij mijn weten kan je alleen in de iptables niet de netwerkkaart/interface vermelden en ik krijg natuurlijk problemen als ik van IP verwissel terwijl mijn ppp0 up blijft.

 

Waarom kan je met een routertje van 20 Euro wel zonder problemen forwarden en geeft het geen makkelijke oplossing qua software ? :-)

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites

No sigar :

 

mrrepel@server:~$ sudo iptables -A PREROUTING -d ppp0 -j VSERVER

iptables v1.4.10: host/network `ppp0' not found

Try `iptables -h' or 'iptables --help' for more information.

mrrepel@server:~$

 

Ik vond hier nog een stukje : http://ubuntuforums.org/showthread.php?t=896488&page=2

 

en heb hier dit van gemaakt:

#!/bin/sh

iptables -t filter -F

iptables -t filter -A INPUT -m state --state ESTABLISHED -j ACCEPT

iptables -t filter -A INPUT -p icmp -j ACCEPT

iptables -t filter -A INPUT -p tcp -m tcp -m multiport --dports 8080 -m state --state NEW -j ACCEPT

iptables -t filter -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT

iptables -t filter -A INPUT -p tcp -i eth0 -j ACCEPT

iptables -P FORWARD ACCEPT

iptables -P OUTPUT ACCEPT

iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 8080 -j DNAT --to-destination 10.42.43.64:80

 

Helaas ook geen succes :-(

aangepast door mr|repel

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites

Nog een tijdje aan de gang geweest. Internet delen van Ubuntu staat uit en ik heb de DHCP server, IPtables en Shorewall draaiend met onderstaande config:

 

DHCP

option broadcast-address 10.42.43.255;
option subnet-mask 255.255.255.0;
option routers 10.42.43.1;
#
# Sample configuration file for ISC dhcpd for Debian
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

option domain-name-servers 10.42.43.1;

default-lease-time 86400;
max-lease-time 172800;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}

# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}

# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}
# intranet op eth0
subnet 10.42.43.0 netmask 255.255.255.0 {
option domain-name-servers 10.42.43.1;
option broadcast-address 10.42.43.255;
option subnet-mask 255.255.255.0;
option routers 10.42.43.1;
range 10.42.43.10 10.42.43.100;
# server
host server {
hardware ethernet 70:71:bc:ad:4f:83;
fixed-address 10.42.43.101;
}
}

 

Iptables ( clickable )

 

iptable2.th.jpg

iptable1.th.jpg

 

 

 

Shorewall:

interfaces:

#
# Shorewall version 4.0 - Sample Interfaces File for two-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-interfaces"
###############################################################################
#ZONE INTERFACE	 BROADCAST	 OPTIONS
net	 ppp0 detect routefilter,tcpflags,logmartians,nosmurfs
loc	 eth0 detect routefilter,tcpflags,logmartians,nosmurfs,routeback

 

masq

#
# Shorewall version 4.0 - Sample Masq file for two-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-masq"
###############################################################################
#INTERFACE			 SOURCE		 ADDRESS		 PROTO PORT(S) IPSEC MARK
eth0:10.42.43.1		 eth0		 10.42.43.255 tcp	 8080
eth0:10.42.43.1		 eth0		 $PPP0_IP	 tcp	 8080
ppp0 10.0.0.0/8,\
				 169.254.0.0/16,\
				 172.16.0.0/12,\
				 192.168.0.0/16

 

pramas:

PPP0_IP=$(find_first_interface_address ppp0)

 

Policy

#
# Shorewall version 4.0 - Sample Policy File for two-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-policy"
###############################################################################
#SOURCE		 DEST		 POLICY		 LOG LEVEL	 LIMIT:BURST
$FW			 net			 ACCEPT
loc			 $FW		 ACCEPT
$FW			 loc		 ACCEPT
loc			 net			 ACCEPT
net			 all			 DROP		 info
# THE FOLLOWING POLICY MUST BE LAST
all			 all			 REJECT		 info

 

routestopped

#
# Shorewall version 4.0 - Sample Routestopped File for two-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-routestopped"
##############################################################################
#INTERFACE	 HOST(S)				 OPTIONS
eth0		 -

 

rules

#
# Shorewall version 4.0 - Sample Rules File for two-interface configuration.
# Copyright (C) 2006,2007 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-rules"
#############################################################################################################
#ACTION		 SOURCE		 DEST		 PROTO DEST SOURCE		 ORIGINAL	 RATE		 USER/ MARK
#													 PORT PORT(S)		 DEST		 LIMIT		 GROUP
#
#	 Accept DNS connections from the firewall to the network
#
DNS(ACCEPT)	 $FW			 net
#
#	 Accept SSH connections from the local network for administration
#
SSH(ACCEPT)	 loc			 $FW
#
#	 Allow Ping from the local network
#
Ping(ACCEPT) loc			 $FW

#
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..
#

Ping(DROP)	 net			 $FW

ACCEPT		 $FW			 loc			 icmp
ACCEPT		 $FW			 net			 icmp
#
# forwarding
DNAT	 net loc:10.42.43.59:80 tcp	 8080
DNAT	 loc loc:10.42.43.1	 tcp	 8080		 -		 $PPP0_IP

 

zones

#
# Shorewall version 4.0 - Sample Zones File for two-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-zones"
###############################################################################
#ZONE TYPE OPTIONS				 IN					 OUT
#									 OPTIONS				 OPTIONS
fw	 firewall
net	 ipv4
loc	 ipv4

 

shorewall.conf

###############################################################################
#
# Shorewall Version 4 -- /etc/shorewall/shorewall.conf
#
# For information about the settings in this file, type "man shorewall.conf"
#
# Manpage also online at http://www.shorewall.net/manpages/shorewall.conf.html
###############################################################################
#					 S T A R T U P E N A B L E D
###############################################################################

STARTUP_ENABLED=Yes

###############################################################################
#							 V E R B O S I T Y
###############################################################################

VERBOSITY=1

###############################################################################
#							 L O G G I N G
###############################################################################

LOGFILE=/var/log/messages

STARTUP_LOG=/var/log/shorewall-init.log

LOG_VERBOSITY=2

LOGFORMAT="Shorewall:%s:%s:"

LOGTAGONLY=No

LOGLIMIT=

LOGALLNEW=

BLACKLIST_LOGLEVEL=

MACLIST_LOG_LEVEL=info

TCP_FLAGS_LOG_LEVEL=info

SMURF_LOG_LEVEL=info

LOG_MARTIANS=Yes

###############################################################################
#	 L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################

IPTABLES=

IP=

TC=

IPSET=

PERL=/usr/bin/perl

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin

SHOREWALL_SHELL=/bin/sh

SUBSYSLOCK=""

MODULESDIR=

CONFIG_PATH=/etc/shorewall:/usr/share/shorewall

RESTOREFILE=

IPSECFILE=zones

LOCKFILE=

###############################################################################
#			 D E F A U L T A C T I O N S / M A C R O S
###############################################################################

DROP_DEFAULT="Drop"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"

###############################################################################
#					 R S H / R C P C O M M A N D S
###############################################################################

RSH_COMMAND='ssh ${root}@${system} ${command}'

RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'

###############################################################################
#					 F I R E W A L L O P T I O N S
###############################################################################

IP_FORWARDING=On

ADD_IP_ALIASES=No

ADD_SNAT_ALIASES=No

RETAIN_ALIASES=No

TC_ENABLED=Internal

TC_EXPERT=No

TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"

CLEAR_TC=Yes

MARK_IN_FORWARD_CHAIN=No

CLAMPMSS=Yes

ROUTE_FILTER=Yes

DETECT_DNAT_IPADDRS=No

MUTEX_TIMEOUT=60

ADMINISABSENTMINDED=Yes

BLACKLISTNEWONLY=Yes

MODULE_SUFFIX=ko

DISABLE_IPV6=No

DYNAMIC_ZONES=No

PKTTYPE=Yes

NULL_ROUTE_RFC1918=No

MACLIST_TABLE=filter

MACLIST_TTL=

SAVE_IPSETS=No

MAPOLDACTIONS=No

FASTACCEPT=No

IMPLICIT_CONTINUE=No

HIGH_ROUTE_MARKS=No

OPTIMIZE=0

EXPORTPARAMS=No

EXPAND_POLICIES=Yes

KEEP_RT_TABLES=No

DELETE_THEN_ADD=Yes

MULTICAST=No

DONT_LOAD=

AUTO_COMMENT=Yes

MANGLE_ENABLED=Yes

USE_DEFAULT_RT=No

RESTORE_DEFAULT_ROUTE=Yes

AUTOMAKE=No

WIDE_TC_MARKS=No

TRACK_PROVIDERS=No

ZONE2ZONE=2

ACCOUNTING=Yes

DYNAMIC_BLACKLIST=Yes

OPTIMIZE_ACCOUNTING=No

LOAD_HELPERS_ONLY=No

REQUIRE_INTERFACE=No

FORWARD_CLEAR_MARK=

COMPLETE=No

EXPORTMODULES=Yes

###############################################################################
#					 P A C K E T D I S P O S I T I O N
###############################################################################

BLACKLIST_DISPOSITION=DROP

MACLIST_DISPOSITION=REJECT

TCP_FLAGS_DISPOSITION=DROP

#LAST LINE -- DO NOT REMOVE

Ik heb deze howto gevolgd: http://ubuntuforums....ad.php?t=926001

Als ik in dit voorbeeld de NAT gebruik voor de port te forwarden klapt mijn internet eruit ( gebruik makende van IP tables ). Hierna ben ik met shorewall aan de gang gegaan. Uit een FAQ van shorewall bleek dat het interne netwerk de port forward niet ziet, enkel het externe netwerk http://www.shorewall.net/FAQ.htm#faq2 vandaar een aantal toevoegingen.

 

Helaas nog steeds geen succes.

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites

  • 2 maanden later...

Ja, alleen ik zag het zelf niet, de rest van de wereld wel zeg maar. De poort wordt alleen van buiten naar binnen geforward, van binnen naar buiten zie je deze forward niet.

Greetz

 

Mr|Repel

 

There are 10 kinds of people in the world

Those who understand binairy and those who don't

 

 

 

Link naar reactie
Delen op andere sites

Maak een account aan of log in om te reageren

Je moet een lid zijn om een reactie te kunnen achterlaten

Account aanmaken

Registreer voor een nieuwe account in onze community. Het is erg gemakkelijk!

Registreer een nieuwe account

Inloggen

Heb je reeds een account? Log hier in.

Nu inloggen
×
×
  • Nieuwe aanmaken...