Usiadłem dzisiaj żeby to się człowiekowi nie nudziło do komputera i napisałem mój pierwszy router. Potrzebuje trochę porad. Na początek mój serwer:
[INDENT]łącze:
[INDENT]pobieranie 3,5Mbit/s
wysyłanie: 3,5Mbit/s[/INDENT][/INDENT]
Internet na eth0>nat>eth1 192.168.1.0/24
Kod: Zaznacz cały
ifconfig
Kod: Zaznacz cały
eth0 Link encap:Ethernet HWaddr 00:50:7f:aa:15:c1
inet addr:80.48.4.229 Bcast:80.48.4.255 Mask:255.255.255.224
inet6 addr: fe80::250:7fff:feaa:15c1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:94178 errors:0 dropped:0 overruns:0 frame:0
TX packets:34567 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22615295 (21.5 MiB) TX bytes:3882408 (3.7 MiB)
Interrupt:252 Base address:0x4000
eth1 Link encap:Ethernet HWaddr 00:10:5a:c9:46:e0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::210:5aff:fec9:46e0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:244265 errors:0 dropped:0 overruns:0 frame:0
TX packets:503461 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18052988 (17.2 MiB) TX bytes:750115314 (715.3 MiB)
Interrupt:21 Base address:0x6c00
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:89 errors:0 dropped:0 overruns:0 frame:0
TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8547 (8.3 KiB) TX bytes:8547 (8.3 KiB)
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
allow-hotplug eth0
iface eth0 inet dhcp
Kod: Zaznacz cały
#!/bin/sh
ifconfig eth0 down
ifconfig eth0 hw ether 00:50:7f:aa:15:c1
dhclient eth0
ifconfig eth1 192.168.1.1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
#Czyszczenie tablic
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
#Domyslna polityka dzialania
iptables -t filter -P INPUT ACCEPT
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT ACCEPT
#Utrzymywanie polaczen nawiazanych
#przekierowanie pakietow, obie strony
iptables -t filter -A FORWARD -s 192.168.1.0/255.255.255.0 -d 0/0 -j ACCEPT
iptables -t filter -A FORWARD -s 0/0 -d 192.168.1.0/255.255.255.0 -j ACCEPT
#Nat- zamienianie z Ip wew na zew.
iptables -t nat -A POSTROUTING -s 192.168.1.0/16 -o eth0 -j SNAT --to-source 80.48.4.229
#Blokowanie odpowiedzi na ping
iptables -t filter -A INPUT -p icmp --icmp-type echo-request -j DROP
#Odblokowanie icmp w sieci
iptables -t filter -A INPUT -i eth1 -p icmp --icmp-type echo-request -j ACCEPT
#Przekierowania portów
#iptables -t nat -A PREROUTING -p tcp -i eth0 -s 0/0 --dport 1550 -j DNAT --to 192.168.1.10
#iptables -t nat -A PREROUTING -p udp -i eth0 -s 0/0 --dport 1550 -j DNAT --to 192.168.1.10
#Krztaltowanieruchu
#Czyszczenie wpisow
tc qdisc del root dev eth0
tc qdisc del root dev eth1
#Tworzenie klasy domyslnej
tc qdisc add dev eth root handle 1:0 htb default
#Okreslanie maksymalnej predkosci lacza
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 3mbit ceil 3584kbps
#Klasa dla pozostalych pakietow
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 256kbps ceil 512kbps
#Definicje klas dla poszczegolnych uslug
#SSH+SIP
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 758kbps ceil 1mbit
#SIP
tc class add dev eth0 parent 1:3 classid 1:30 htb rate 379kbps ceil 758kbps
tc class add dev eth0 parent 1:3 classid 1:31 htp rate 379kbps ceil 758kbps
#Komputery
tc class add dev eth0 parent 1:1 classid 1:4 htb rate 2048kbps ceil 3mbit
tc class add dev eth0 parent 1:1 classid 1:40 htb rate 1024kbps ceil 2048kbps
tc class add dev eth0 parent 1:5 classid 1:41 htb rate 1024kbps ceil 2048kbps
#Filtr
tc filter add dev eth0 protocol ip parent 1:0 u32 match ip sport 22 0xffff flowid 1:31
#Deklaracja lacza dla hosta
##BramkaVoiP
tc filter add dev eth0 protocol ip parent 1:0 u32 match ip dst 192.168.1.104 flowid 1:30
##S&S
tc filter add dev eth0 protocol ip parent 1:0 u32 match ip dst 192.168.1.100 flowid 1:40
tc filter add dev eth0 protocol ip parent 1:0 u32 match ip dst 192.168.1.103 flowid 1:41
hostname ispons.pl
killall -9 dhcpd
dhcpd eth1
I moje ostatnie pytanie wszędzie jest:
Kod: Zaznacz cały
add dev eth0