PPPoEd е PPPoE сървър, но и без него пак не става.
Пълната картина
xxx.xxx.xxx.xxx - външният ми IP адрес
xxx.xxx.xxx.0 - ISP мрежата
xxx.xxx.xxx.1 - ISP gateway
dns.dns.dns.dns - ISP DNS
10.11.12.0 - локалната ми (вътрeшна) мрежа
10.11.12.13 - вътрешният ми адрес (на Debian машината, рутера)
10.11.12.14 - другият компютър (vista машината, към която искам да пренасочвам пакетите)
eth0 - вътрешният interface (локалната мрежа)
eth1 - външният interface
в /proc/sys/net/ipv4/ip_forward
1
в /etc/sysctl.conf
net.ipv4.conf.default.forwarding=1
net.ipv4.ip_forward = 1
ifconfig -a
Примерен код |
eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx inet addr:10.11.12.13 Bcast:10.11.12.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3997 errors:0 dropped:0 overruns:69 frame:0 TX packets:4965 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:652783 (637.4 KiB) TX bytes:4246737 (4.0 MiB) Interrupt:177 Base address:0x4c00 eth1 Link encap:Ethernet HWaddr yy:yy:yy:yy:yy:yy inet addr:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:21830 errors:0 dropped:0 overruns:0 frame:0 TX packets:6528 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6875496 (6.5 MiB) TX bytes:1152166 (1.0 MiB) Interrupt:169 Base address:0xd800 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:4046 errors:0 dropped:0 overruns:0 frame:0 TX packets:4046 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1270416 (1.2 MiB) TX bytes:1270416 (1.2 MiB) sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 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) |
route -n
Примерен код |
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface xxx.xxx.xxx.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 10.11.12.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 xxx.xxx.xxx.1 0.0.0.0 UG 0 0 0 eth1 |
Ползвам следния script:
Примерен код |
EXT=eth1 INT=eth0 iptables -F iptables -t nat -F iptables -t mangle -F iptables -X # Always accept loopback traffic iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -m state --state NEW -i ! $EXT -j ACCEPT iptables -A FORWARD -i $EXT -o $INT -m state --state ESTABLISHED,RELATED -j ACCEPT # Accept outgoing packets from internal network iptables -A FORWARD -i $INT -o $EXT -j ACCEPT iptables -t nat -A POSTROUTING -o $EXT -j MASQUERADE # TTL settings iptables -t mangle -A PREROUTING -i $EXT -j TTL --ttl-inc 1 iptables -t mangle -A POSTROUTING -s 10.11.12.0/24 -o $EXT -j TTL --ttl-set 64 # port 8080 to port 80 iptables -t nat -A PREROUTING -p tcp -i eth1 -d xxx.xxx.xxx.xxx --dport 8080 -j DNAT --to 10.11.12.14:80 iptables -A FORWARD -p tcp -i eth1 -d 10.11.12.14 --dport 80 -j ACCEPT |
iptables -L -n
Примерен код |
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 state NEW Chain FORWARD (policy ACCEPT) target prot opt source destination ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 10.11.12.14 tcp dpt:80 Chain OUTPUT (policy ACCEPT) target prot opt source destination |
iptables -t nat -L -n
Примерен код |
Chain PREROUTING (policy ACCEPT) target prot opt source destination DNAT tcp -- 0.0.0.0/0 xxx.xxx.xxx.xxx tcp dpt:8080 to:10.11.12.14:80 Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE 0 -- 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT) target prot opt source destination |
iptables -t mangle -L -n
Примерен код |
Chain PREROUTING (policy ACCEPT) target prot opt source destination TTL 0 -- 0.0.0.0/0 0.0.0.0/0 TTL increment by 1 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 Chain POSTROUTING (policy ACCEPT) target prot opt source destination TTL 0 -- 10.11.12.0/24 0.0.0.0/0 TTL set to 64 |
вътрешната машина (която ползва vista)
ipconfig -all
Примерен код |
Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : 10/100 Ethernet Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes IPv4 Address. . . . . . . . . . . : 10.11.12.14(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.11.12.13 DNS Servers . . . . . . . . . . . : dns.dns.dns.dns NetBIOS over Tcpip. . . . . . . . : Enabled |
когато напиша http://10.11.12.14:80 виждам index.html на вътрешната машина
когато напиша http://xxx.xxx.xxx.xxx:80 виждам index.html на външната машина
когато напиша http://xxx.xxx.xxx.xxx:8080 отново виждам index.html на външната мапина, вместо index.html на вътрешната машина
(външната ми машина слуша и на двата порта 80 и 8080, вътрешната - само на 80)
Мисля, че има проблем със следния ред в таблицата с маршрутите
10.11.12.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0