All pastes #115614 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-08-04 18:54 UTC
rendered paste body
INTERNALNIC=eth0
EXTERNALNICA=eth1
EXTERNALNICB=eth2

EXTERNALIP=0.0.0.0

#clean up for restart
ip rule del fwmark 1 table interfacea.out
ip rule del fwmark 2 table interfaceb.out

#add rules to route packets marked with 1 with interfacea routing table
#and packets marked with 2 with interfaceb routing table
#you will need to have created these routing tables
ip rule add fwmark 1 table interfacea.out
ip rule add fwmark 2 table interfaceb.out

#delete default route
ip route del default

#add default route through interfacea
ip route add default via $externalipaddress dev $EXTERNALNICA table main

#set default route for interfacea routing table through interfacea
ip route del default table interfacea.out
ip route add default via $EXTERNALIPA dev $EXTERNALNICA table interfacea.out

#set default route for interfaceb routing table through interfaceb
ip route del default table interfaceb.out
ip route add default via $EXTERNALIPB dev $EXTERNALNICB table interfaceb.out

#mark everything for connection 1

iptables -t mangle -A PREROUTING -i $INTERNALNIC -d 0/0 -j MARK --set-mark 1

#now mark stuff we want to go over connection2

#ssh
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 22 -j MARK --set-mark 2

#http(s)
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 80 -j MARK --set-mark 2
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 443 -j MARK --set-mark 2

#irc
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 6667  -j MARK --set-mark 2
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 6669  -j MARK --set-mark 2 #ssl
iptables -A PREROUTING -i internal -t mangle -p tcp --dport 7070  -j MARK --set-mark 2 #freenode alternative port

#put a specific machine on one connection

iptables -A PREROUTING -i internal -t mangle -p udp -s 192.168.0.30 -j MARK --set-mark 2
iptables -A PREROUTING -i internal -t mangle -p tcp -s 192.168.0.30 -j MARK --set-mark 2