Witam.
Mam problem z udostępnieniem internetu z routera poprzez serwer (debian wheezy) do komputerów w sieci, połączonych ze sobą switchem. Infrastruktura wygląda tak jak na obrazku:
Krótkie objaśnienie: na routerze serwer ma ustawiony statyczny adres IP (192.168.1.254). Wszystkie komputery otrzymują adres IP poprzez DHCP serwera. Eth1 - interface sieci LAN, eth2 - interface od routera (czyli dostarczający internet)
konfiguracja /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth2
iface eth2 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.25.100
netmask 255.255.255.0
Wynik zapytania ifconfig
eth1 Link encap:Ethernet HWaddr 00:15:17:1e:c7:58
inet addr:192.168.25.100 Bcast:192.168.25.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe1e:c758/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:592 errors:0 dropped:0 overruns:0 frame:0
TX packets:991 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:58815 (57.4 KiB) TX bytes:218310 (213.1 KiB)
Interrupt:17 Memory:e8180000-e81a0000
eth2 Link encap:Ethernet HWaddr 00:15:17:1e:c7:59
inet addr:192.168.1.254 Bcast:255.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe1e:c759/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:374813 errors:0 dropped:0 overruns:0 frame:0
TX packets:2657237369 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:127476343 (121.5 MiB) TX bytes:1964327902616 (1.7 TiB)
wynik /etc/dhcp3/dhcpd.conf
ddns-update-style none;
option domain-name "splocal";
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.25.0 netmask 255.255.255.0 {
range 192.168.25.1 192.168.25.254;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.25.255;
option routers 192.168.25.100;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option routers pepper.spices.org;
} authorative;
i na koniec lista iptables:
# 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
iptables -t mangle -F
iptables -t mangle -X
# ustawienie domyslnej polityki
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# utrzymanie polaczen nawiazanych
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.25.0/24 -j MASQUERADE
iptables -A FORWARD -s 192.168.25.0/24 -j ACCEPT
EDIT: wynik ip route show
default via 192.168.1.1 dev eth2
192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.254
192.168.25.0/24 dev eth1 proto kernel scope link src 192.168.25.100
cat /proc/sys/net/ipv4/ip_forward
1
iptables -nvL
Chain INPUT (policy ACCEPT 5460 packets, 559K bytes)
pkts bytes target prot opt in out source destination
3395 1293K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT all -- * * 192.168.25.0/24 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 204M packets, 33G bytes)
pkts bytes target prot opt in out source destination
2974 309K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 1127 packets, 162K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 994 packets, 147K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 27M packets, 5034M bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 27M packets, 5034M bytes)
pkts bytes target prot opt in out source destination
28 4403 MASQUERADE all -- * * 192.168.25.0/24 0.0.0.0/0
Do tej pory udało mi się sprawić, że komputery w sieci dostają adres IP i mogą siebie nawzajem pingować. Nie mogę jednak udostępnić internetu. Polecenie ping -I eth1 google.pl nic nie pokazuje (na eth2 działa ok).
Z góry dziękuję za każdą pomoc w znalezieniu błędu w tej konfiguracji.