Od pewnego czasu staram się skonfigurować ruter (połączenie kilku poradników oraz skryptu V-Smart Router).
Na razie uruchomiłem DHCP (które działa bez problemów) oraz firewalla (który też dla wewnętrznej adresacji się sprawuje).
Jednak mam ogromny problem z ustaleniem trasy pojedynczych, zewnętrznych adresów IP, dla kolejnych serwerów (i klientów).
Moje parametry:
- Debian6
- IP przyłączeniowe 213.134.XXX.66
- klasa IP przyznana przez dostawcę internetu: 77.236.XX.XX
Plik interfaces:
Kod: Zaznacz cały
auto eth0
iface eth0 inet static
address 213.134.XX.66
gateway 213.134.XX.65
netmask 255.255.255.252
broadcast 213.134.XX.67
auto eth1
iface eth1 inet static
address 77.236.XX.1
broadcast 77.236.XX.255
netmask 255.255.255.0
dhcpd.conf:
Kod: Zaznacz cały
ddns-update-style none;
subnet 77.236.XX.0 netmask 255.255.255.0 {
max-lease-time 86400;
option routers 77.236.XX.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 77.236.XX.1, 212.76.34.50, 8.8.8.8;
# ADRESY I MACZKI KLIENTOW
host 24-9 { fixed-address 77.236.XX.9; hardware ethernet 94:0C:6D:C3:23:0D; }
host 24-10 { fixed-address 77.236.XX.10; hardware ethernet 00:19:E3:E5:6E:78; }
host 24-11 { fixed-address 77.236.XX.11; hardware ethernet 00:13:8F:79:CF:A4; }
host 24-13 { fixed-address 77.236.XX.13; hardware ethernet 00:24:01:8F:82:69; }
host 24-14 { fixed-address 77.236.XX.14; hardware ethernet C8:3A:35:3E:2E:45; }
host 24-15 { fixed-address 77.236.XX.15; hardware ethernet 00:00:27:24:74:78; }
host 24-16 { fixed-address 77.236.XX.16; hardware ethernet 00:0D:88:2F:81:82; }
host 24-17 { fixed-address 77.236.XX.17; hardware ethernet 00:0A:CD:04:CD:ED; }
host 24-18 { fixed-address 77.236.XX.18; hardware ethernet 00:25:86:C2:F7:1B; }
host 24-19 { fixed-address 77.236.XX.19; hardware ethernet B0:48:7A:C8:14:15; }
host 24-20 { fixed-address 77.236.XX.20; hardware ethernet 00:19:66:40:A2:87; }
host 24-21 { fixed-address 77.236.XX.21; hardware ethernet 00:10:DC:41:CF:EB; }
host 24-22 { fixed-address 77.236.XX.22; hardware ethernet 00:24:21:50:DC:00; }
host 24-23 { fixed-address 77.236.XX.23; hardware ethernet 4C:00:10:61:0D:D4; }
host 24-33 { fixed-address 77.236.24.33; hardware ethernet 00:1C:F0:53:56:3F; }
host 24-39 { fixed-address 77.236.24.39; hardware ethernet 00:1B:11:F4:2A:A1; }
}
shared-network eth1 {
option domain-name "domena.pl";
option domain-name-servers 192.168.34.1, 212.76.34.49, 212.76.34.50, 8.8.8.8;
option subnet-mask 255.255.255.0;
max-lease-time 86400;
subnet 192.168.34.0 netmask 255.255.255.0 {
option routers 192.168.34.1;
host 34-2 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.34.2; }
}
}
Kod: Zaznacz cały
/usr/sbin/ip a a 192.168.34.1/24 brd 192.168.34.255 dev eth1
/usr/sbin/ip a a 192.168.78.1/24 brd 192.168.78.255 dev eth1
/usr/sbin/ip link set eth1 up
#SERWERY
/usr/sbin/ip r a 77.236.XX.2 dev eth1
/usr/sbin/ip r a 77.236.XX.3 dev eth1
/usr/sbin/ip r a 77.236.XX.4 dev eth1
/usr/sbin/ip r a 77.236.XX.5 dev eth1
/usr/sbin/ip r a 77.236.XX.6 dev eth1
/usr/sbin/ip r a 77.236.XX.7 dev eth1
/usr/sbin/ip r a 77.236.XX.8 dev eth1
#KLIENCI (1 dla testow)
/usr/sbin/ip r a 77.236.XX.9 dev eth1
/etc/init.d/isc-dhcp-server restart
exit 0
Kod: Zaznacz cały
#!/bin/bash
# zalaczenie [b]przekierowania[/b] w [b]jadrze[/b]
echo 1 > /proc/sys/net/ipv4/ip_forward
# czyszczenie starych regul
iptables -F
iptables -Z
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
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH ACK -j DROP
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN -j DROP
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN,URG,PSH -j DROP
# 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.34.2/32 -j MASQUERADE
iptables -A FORWARD -s 192.168.34.2/32 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.78.0/24 -j MASQUERADE
iptables -A FORWARD -s 192.168.78.0/24 -j ACCEPT
iptables -A INPUT -s 77.236.XX.0/24 -j ACCEPT
iptables -A INPUT -d 77.236.XX.0/24 -j ACCEPT
iptables -A OUTPUT -s 77.236.XX.0/24 -j ACCEPT
iptables -A OUTPUT -d 77.236.XX.0/24 -j ACCEPT
iptables -A FORWARD -s 77.236.XX.0/24 -j ACCEPT
iptables -A FORWARD -d 77.236.XX.0/24 -j ACCEPT
#iptables -A INPUT -j ACCEPT
#iptables -A FORWARD -j ACCEPT
#iptables -A OUTPUT -j ACCEPT
Kod: Zaznacz cały
auto eth0
iface eth0 inet static
address 77.236.XX.2
gateway 77.236.XX.1
netmask 255.255.255.0