Strona 1 z 2
[+] przekierowanie z eth0 przez wlan1 do wlan0
: 15 listopada 2009, 23:40
autor: zomer
Witam.
Mam dwie karty sieciowe na komputerze stacjonarnym (eth0 połączona z internetem) i (wlan1 na której chcę udostępnić internet)
Skorzystałem z tej porady
http://stary.dug.net.pl/texty/masq.php
Mój
/etc/interfaces
Kod: Zaznacz cały
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.2.115
netmask 255.255.255.0
network 192.168.2.1
broadcast 192.168.2.255
gateway 192.168.2.1
auto wlan1
iface wlan1 inet static
address 192.168.1.1
netmask 255.255.255.0
Wykonałem to polecenie
i wyczyściłem iptables
Kod: Zaznacz cały
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Teraz na laptopie sprawdziłem
Brak połączenia, pingi nie wracają.
Ktoś wie jak zrobić przekierowanie z
eth0 prze
wlan1 od laptopa na
wlan0
: 15 listopada 2009, 23:52
autor: gruby
http://dug.net.pl/tekst/31/udostepnieni ... 28masq%29/ <- tu masz uaktualniony, a tak na poważnie to nie zrobiłeś "MASQUERADE"
: 15 listopada 2009, 23:55
autor: darkwater
zomer pisze:i wyczyściłem iptables
a przecież w poradniku który linkujesz wyraźnie jest napisane:
Kod: Zaznacz cały
# wlaczenie w kernelu forwardowania
echo 1 > /proc/sys/net/ipv4/ip_forward
# czyszczenie starych regul
iptables -F
iptables -X
iptables -t nat -X
iptables -t nat -F
# ustawienie polityki dzialania
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# zezwolenie nna laczenie sie z naszym zewnetrznym ip po ssh
iptables -A INPUT -i lo -j ACCEPT
iptables -A FORWARD -o lo -j ACCEPT
iptables -A INPUT -s 0/0 -d ip.ip.ip.ip -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d ip.ip.ip.ip -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 0/0 -d ip.ip.ip.ip -p udp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d ip.ip.ip.ip -p udp --dport 22 -j ACCEPT
# polaczenia nawiazane
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
# udostepniaie internetu w sieci lokalnej
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
: 16 listopada 2009, 10:37
autor: fnmirk
Przedstaw wynik polecenia:
i:
: 17 listopada 2009, 00:41
autor: zomer
Zrobiłem jak w instrukcji
touch /etc/init.d/firewall
chmod +x /etc/init.d/firewall
Wykonanie skryptu....
ifconfig -a
Kod: Zaznacz cały
eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.2.115 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::21d:92ff:fe33:8e77/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3195 errors:0 dropped:0 overruns:0 frame:0
TX packets:2580 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:681723 (665.7 KiB) TX bytes:241970 (236.2 KiB)
Interrupt:26 Base address:0xe000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1146 errors:0 dropped:0 overruns:0 frame:0
TX packets:1146 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:86520 (84.4 KiB) TX bytes:86520 (84.4 KiB)
pan0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
vboxnet0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wmaster0 Link encap:UNSPEC HWaddr 00-4F-6A-04-E3-7A-00-00-00-00-00-00-00-00-00-00
UP RUNNING MTU:0 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ifconfig
Kod: Zaznacz cały
eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.2.115 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::21d:92ff:fe33:8e77/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3402 errors:0 dropped:0 overruns:0 frame:0
TX packets:2828 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:797366 (778.6 KiB) TX bytes:321344 (313.8 KiB)
Interrupt:26 Base address:0xe000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1146 errors:0 dropped:0 overruns:0 frame:0
TX packets:1146 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:86520 (84.4 KiB) TX bytes:86520 (84.4 KiB)
wlan1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wmaster0 Link encap:UNSPEC HWaddr 00-4F-6A-04-E3-7A-00-00-00-00-00-00-00-00-00-00
UP RUNNING MTU:0 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Kod: Zaznacz cały
ping 192.168.1.1 ==> wykonany na serverze (komputer stacjonarny)
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.055 ms
----------------------------------
=== Wykonane na laptopie ===
Kod: Zaznacz cały
ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:5802 errors:0 dropped:0 overruns:0 frame:0
TX packets:5802 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:314481 (307.1 KiB) TX bytes:314481 (307.1 KiB)
wlan0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::221:5dff:fea2:144/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:6361 errors:0 dropped:0 overruns:0 frame:0
TX packets:8617 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1098648 (1.0 MiB) TX bytes:743783 (726.3 KiB)
wmaster0 Link encap:UNSPEC HWaddr 00-21-5D-A2-01-44-00-00-00-00-00-00-00-00-00-00
UP RUNNING MTU:0 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Kod: Zaznacz cały
ping -I wlan0 192.168.1.1
PING 192.168.1.1 (192.168.1.1) from 192.168.1.2 wlan0: 56(84) bytes of data.
From 192.168.1.2 icmp_seq=1 Destination Host Unreachable
From 192.168.1.2 icmp_seq=2 Destination Host Unreachable
From 192.168.1.2 icmp_seq=3 Destination Host Unreachable
From 192.168.1.2 icmp_seq=4 Destination Host Unreachable
From 192.168.1.2 icmp_seq=5 Destination Host Unreachable
Mnie jeszcze taka
rzecz ciekawi. jak sieć wlan
iwlist wlan0 scan ma być odnaleziona skoro do jej konfiguracji potrzebna jest jej nazwa (wprawdzie adresy na laptopie wpisałem ręcznie jak w instrukcji) no ale instrukcja jest do eth0, eth1,. Na ruterze sprzętowym nazwę się ustala, a w Debianie nie mam pojęcia jak to zrobić. Sądziłem że to będzie nazwa hosta, ale nie została wykryta.
Nazwa sieci wlan to jest ta różnica między przekazywaniem połączenia eth0 → eth1, tak mi się wydaje.
: 17 listopada 2009, 01:17
autor: fnmirk
Przedstaw jeszcze plik:
Możesz mieć inne oznaczenie zamiast ,,70''.
: 17 listopada 2009, 10:02
autor: mariaczi
Laptop z komputerem stacjonarnym połączyły się siecią bezprzewodową? Karta w stacjonarnym pracuje jako AP?
: 17 listopada 2009, 10:27
autor: zomer
Kod: Zaznacz cały
cat /etc/udev/rules.d/70-persistent-net.rules
Kod: Zaznacz cały
# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# PCI device 0x1814:0x0301 (rt61pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan1"
: 17 listopada 2009, 11:55
autor: fnmirk
Czy widzisz teraz, która karta jest przypisana fizycznie danemu interfejsowi? Jeżeli tak, to sprawdź połączenia lub narysuj schemat sieci i przedstaw go na forum.
Jak zamienisz fizycznie karty miejscami to musisz usunąć wszystkie wpisy z pliku /etc/udev/rules.d/70-persistent-net.rules, zapisać zmiany i następnie zrestartować komputer aby udev rozpoznał karty ponownie.
: 18 listopada 2009, 00:34
autor: zomer
Zrobiłem jak radziłeś. Już nie mam "wlan1" na stacjonarnym komputerze tylko "wlan0"
Kod: Zaznacz cały
cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1d:92:33:8e:77", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1814:0x0301 (rt61pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:4f:6a:04:e3:7a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0
Schemat jest taki: [router (neostrada ADSL)→192.168.2.1] →kabel ethernet→ [eth0 (192.168.2.115)] → forward→[wlan0 (192.168.1.1)] →udostępnienie do laptopa przez wifi→ [wlan0 (192.168.1.2)]