Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I got the following route table :

#!/bin/bash
IP=/sbin/ip

# SST
echo "SST: Setting up SST network ..."
$IP route flush table 10
$IP route add table 10 to 10.45.13.0/26 dev eth0
$IP route add table 10 to default via 10.100.36.1 dev eth0
$IP rule add from 10.45.13.0/26 table 10 priority 10
$IP route flush cache
echo "SST: SST network routing in place."

# Expotools
echo "SST: Setting up Expotools network ..."
$IP route flush table 20
$IP route add table 20 to 10.45.15.0/26 dev eth3
$IP route add table 20 to default via 10.200.36.1 dev eth3
$IP rule add from 10.45.15.0/26 table 20 priority 20
$IP route flush cache
echo "SST: Expotools network routing in place."

echo "SST: Others routing settings...."
route add default gw 10.100.36.1

root@ROUTER-DEB:/sst/scripts# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.200.36.0     0.0.0.0         255.255.255.248 U     30     0        0 eth3
10.100.36.0     0.0.0.0         255.255.255.248 U     40     0        0 eth0
10.45.15.0      0.0.0.0         255.255.255.192 U     5      0        0 eth2
10.45.13.0      0.0.0.0         255.255.255.192 U     10     0        0 eth1
0.0.0.0         10.100.36.1     0.0.0.0         UG    0      0        0 eth0
0.0.0.0         10.45.15.1      0.0.0.0         UG    5      0        0 eth2
0.0.0.0         10.45.13.1      0.0.0.0         UG    10     0        0 eth1
0.0.0.0         10.200.36.1     0.0.0.0         UG    30     0        0 eth3
0.0.0.0         10.100.36.1     0.0.0.0         UG    40     0        0 eth0

All of my computers on 10.45.13.0/26 and 10.45.15.0/26 are unable to ping 10.45.13.1 and 10.45.15.1 but can be everyting on 10.100.36.0 and 10.200.36.0.

IPTables :

ET_BELL=eth0
ET_VIDEOTRON=eth3
ET_SST=eth1
ET_EXPOTOOLS=eth2

# On va vider le contenu de IPTables
echo "SST: Cleaning IPTables content..."
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X

echo "SST: Accepting all incoming lo data..."
iptables -A INPUT -i lo -j ACCEPT

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -A INPUT -m state --state NEW ! -i $ET_BELL -j ACCEPT
iptables -A FORWARD -i $ET_BELL -o $ET_SST -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW ! -i $ET_VIDEOTRON -j ACCEPT
iptables -A FORWARD -i $ET_VIDEOTRON -o $ET_EXPOTOOLS -m state --state ESTABLISHED,RELATED -j ACCEPT

echo "SST: Opening ports..."
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -p igmp -j ACCEPT

echo "SST: Forwarding Bell to SST Network..."
iptables -A FORWARD -i $ET_BELL -o $ET_SST -j ACCEPT
echo "SST: Forwarding Videotron to Expotools Network..."
iptables -A FORWARD -i $ET_VIDEOTRON -o $ET_EXPOTOOLS -j ACCEPT

echo "SST: Activation of BELL/SST NAT..."
iptables -t nat -A POSTROUTING -o $ET_BELL -j MASQUERADE
echo "SST: Activation of Videotron/Expotools NAT..."
iptables -t nat -A POSTROUTING -o $ET_VIDEOTRON -j MASQUERADE

echo "SST: Forwarding SQUID3..."
iptables -t nat -A PREROUTING -i $ET_SST -p tcp --dport 80 -j DNAT --to 10.100.36.2:3128
iptables -t nat -A PREROUTING -i $ET_EXPOTOOLS -p tcp --dport 80 -j DNAT --to 10.200.36.2:3128

iptables -A FORWARD -i $ET_SST -o $ET_EXPOTOOLS -j REJECT
iptables -A FORWARD -i $ET_EXPOTOOLS -o $ET_SST -j REJECT
iptables -A FORWARD -i $ET_BELL -o $ET_BELL -j REJECT
iptables -A FORWARD -i $ET_VIDEOTRON -o $ET_VIDEOTRON -j REJECT

root@ROUTER-DEB:/etc/bind# ifconfig
eth0      Link encap:Ethernet  HWaddr 30:85:a9:ad:54:1e
          inet addr:10.100.36.2  Bcast:10.100.36.7  Mask:255.255.255.248
          inet6 addr: fe80::3285:a9ff:fead:541e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4808477 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3617658 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4984207655 (4.6 GiB)  TX bytes:972655869 (927.5 MiB)
          Interrupt:27 Base address:0xe000

eth1      Link encap:Ethernet  HWaddr a0:f3:c1:04:64:40
          inet addr:10.45.13.1  Bcast:10.45.13.63  Mask:255.255.255.192
          inet6 addr: fe80::a2f3:c1ff:fe04:6440/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25385197 errors:0 dropped:9143 overruns:0 frame:0
          TX packets:15372440 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:32206688027 (29.9 GiB)  TX bytes:5934594299 (5.5 GiB)
          Interrupt:17 Base address:0x4000

eth2      Link encap:Ethernet  HWaddr a0:f3:c1:04:a0:2f
          inet addr:10.45.15.1  Bcast:10.45.15.63  Mask:255.255.255.192
          inet6 addr: fe80::a2f3:c1ff:fe04:a02f/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:36936 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45462 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5640732 (5.3 MiB)  TX bytes:43909441 (41.8 MiB)
          Interrupt:18 Base address:0x8000

eth3      Link encap:Ethernet  HWaddr 28:10:7b:c9:58:76
          inet addr:10.200.36.2  Bcast:10.200.36.7  Mask:255.255.255.248
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1619 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:233263 (227.7 KiB)  TX bytes:922 (922.0 B)
          Interrupt:19 Base address:0xc000

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:8477 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8477 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1000859 (977.4 KiB)  TX bytes:1000859 (977.4 KiB)
share|improve this question
    
Could you list the IP's on each interface? ip add sh ? –  Sandor Marton May 13 '13 at 18:35
    
@SandorMarton Added. –  David Bélanger May 13 '13 at 19:02
    
My routing is working fine. I am not able to reach my server with the gateway address (10.45.13.1 and 10.45.15.1). –  David Bélanger May 13 '13 at 19:07
2  
If you are going to use advanced routing features, then stop using the route command. It simply doesn't return useful information. It doesn't understand multiple route tables. It would be more useful if you gave the output of ip route show table all. Likewise, stop using ifconfig, use ip addr show –  Zoredache May 13 '13 at 19:25
add comment

1 Answer

Try this instead of your rules.
But reboot the route first so all other routes/rules are cleaned (obviously don't load at boot that the previous script)

ip route flush table 10
ip route add 10.45.13.0/26 dev eth1 table 10
ip route add 10.100.36.0/29 dev eth0 table 10
ip route add default via 10.100.36.1 table 10
ip rule add from 10.45.13.0/26 table 10 prio 10

ip route flush table 20
ip route add 10.45.15.0/26 dev eth2 table 20
ip route add 10.200.36.0/29 dev eth3 table 20
ip route add default via 10.200.36.1 table 20
ip rule add from 10.45.15.0/26 table 20 prio 20

ip ro add default via 10.100.36.1

ip ro flush cache
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.