masquerading

Kefalas Apostolos akef at freemail.gr
Sun Jul 4 19:28:24 EEST 2004


Exoume pc2 me 2 interfaces: 
eth0      Link encap:Ethernet  HWaddr 00:30:4F:21:F9:82
          inet addr:192.168.0.4  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21865 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20200 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:1879867 (1.7 Mb)  TX bytes:6960744 (6.6 Mb)
          Interrupt:10 Base address:0x3000

eth1      Link encap:Ethernet  HWaddr 00:C0:26:A6:F8:26
          inet addr:192.168.1.250  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:50 errors:0 dropped:0 overruns:0 frame:0
          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:33286 (32.5 Kb)  TX bytes:5369 (5.2 Kb)
          Interrupt:11 Base address:0x5000

8eloume na kanoume masquerade ta pc pou einai pisw apo to eth0 sto diktyo pou 
einai sto eth1. ara dinoume:

#!/bin/bash
#
echo 1 > /proc/sys/net/ipv4/ip_forward
#
echo "Fluash chans"
#
iptables -P INPUT ACCEPT
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F
#
# For the Internet
#
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j 
ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source 192.168.1.250

apo to pc1 192.168.0.1 mporw na kanw ping to 192.168.0.4 (eth0 sto pc2)
apo to pc1 192.168.0.1 mporw na kanw ping to 192.168.1.250 (eth1 sto pc2)
apo to pc2 mporw na knw ping se ola ta pc kai toy eth0 kai toy eth1

Kernel IP routing table toy pc2
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo

To problhma einai oti apo ta pc toy eth0 den mporw na kanw ping sta pc toy 
eth1

kamia idea????




More information about the Linux-greek-users mailing list