Toon posts:

[BC3] route van poorten met IPCHAINS

Pagina: 1
Acties:

Verwijderd

Topicstarter
wie kan er mij uitleggen hoe ik met ipchains kan door route??
Eth0= INET
eth1= lan 192.168.1.123

ik wil poorten van icq door route
tcp 6660 tot 6670
van mijn pc 192.168.1.1

wie kan uitleggen hoe?

ik had dit -> ipchains -A forward -j MASQ -d 0.0.0.0/0 6660:6670 -s 192.168.1.1 6660:6670

of dit -> ipchains -A forward -j MASQ -d 0.0.0.0/0 6660:6670 -s 192.168.1.1 6660:6670 -i eth0

Verwijderd

Dat kan niet met ipchains alleen!
Dar heb je een portforwarder voor nodig zoals ipmasqadm i.c.m ipchains.
Zie ipmasq.cjb.net

Verder kan je de search gebruiken op GOT, dit soort topics is hier al vele malen voorbij gekomen.

  • Optical
  • Registratie: Juli 2000
  • Laatst online: 02-06-2025
zo :

# ipmasqadm portfw
Usage: portfw -a -P PROTO -L LADDR LPORT -R RADDR RPORT [-p PREF] add entry
portfw -d -P PROTO -L LADDR LPORT [-R RADDR RPORT] delete entry
portfw -f clear table
portfw -l list table
portfw <args> -n no names

PROTO is the protocol, can be "tcp" or "udp"
LADDR is the local interface receiving packets to be forwarded.
LPORT is the port being redirected.
RADDR is the remote address.
RPORT is the port being redirected to.
PREF is the preference level (load balancing, default=10)

:P

If at first you don't succeed, cheat. Repeat until caught. Then lie .


Verwijderd

Forwarding zet je aan met:
echo 1 > /proc/sys/net/ipv4/ip_forward

Uiteraard moet je verkeer toelaten, als je default DENY is. Als je default ACCEPT is zijn onderstaande 2 regels natuurlijk niet nodig. Overigens is het goed om alles dat je blocked met je firewall te loggen met de -l optie. Dat kun je in de logs zien of het je firewall is waardoor je bijvoorbeeld ergens niet bij kunt. (zo kwam ik erachter waarom de mailserver een week "plat" lag)
ipchains -A input -i $LOCAL_INTERFACE_1 -s $LOCALNET_1 -j ACCEPT
ipchains -A output -i $LOCAL_INTERFACE_1 -d $LOCALNET_1 -j ACCEPT

Masquerading doe je met:

# Masquerade internal traffic.
# All internal traffic is masqueraded externally.

ipchains -A forward -i $EXTERNAL_INTERFACE -s $LOCALNET_1 -j MASQ


Wat hierboven staat (reacties boven mij) hoeft volgens mij niet. Ik heb het nog nooit gebruikt en ICQ werkt prima.

Is dat niet alleen nodig voor kernel 2.0.x ???

Oh ja: De $$$-tekens staan voor het gebruik van variabelen. Bovenaan in je script zet je bijvoorbeeld LOCALNET_1="192.168.0.0/24" en vervolgens gebruik je $LOCALNET_1 in de rest van het script. Dat maakt het goed leesbaar, en later makkelijker aan te passen.

Verwijderd

EXTERNAL_INTERFACE="eth0"

in jouw geval :)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
   # Enable TCP SYN Cookie Protection
    echo 1 > /proc/sys/net/ipv4/tcp_syncookies

    # Enable always defragging Protection
    echo 1 > /proc/sys/net/ipv4/ip_always_defrag

    # Enable broadcast echo  Protection
    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

    # Enable bad error message  Protection
    echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

    # Enable IP spoofing protection
    # turn on Source Address Verification
    for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
      echo 1 > $f
    done

    # Disable ICMP Redirect Acceptance
    for f in /proc/sys/net/ipv4/conf/*/accept_redirects; do
      echo 0 > $f
    done

    for f in /proc/sys/net/ipv4/conf/*/send_redirects; do
      echo 0 > $f
    done

    # Disable Source Routed Packets
    for f in /proc/sys/net/ipv4/conf/*/accept_source_route; do
      echo 0 > $f
    done

    # Log Spoofed Packets, Source Routed Packets, Redirect Packets
    for f in /proc/sys/net/ipv4/conf/*/log_martians; do
      echo 1 > $f
    done

    # These modules are necessary to masquerade their respective services.
    /sbin/modprobe ip_masq_ftp

Dit is doorgaans ook niet overbodig. :)

/me vindt dat hij goed is in knippen en plakken :)