Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

port forwarding

By: a guest on Feb 24th, 2010  |  syntax: None  |  size: 3.20 KB  |  hits: 252  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. root@router:~# ifconfig
  2. eth0      Link encap:Ethernet  HWaddr 00:02:2a:db:8e:c7
  3.           inet addr:192.168.0.254  Bcast:192.168.0.255  Mask:255.255.255.0
  4.           inet6 addr: fe80::202:2aff:fedb:8ec7/64 Scope:Link
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  6.           RX packets:56228 errors:0 dropped:0 overruns:0 frame:0
  7.           TX packets:93318 errors:0 dropped:0 overruns:0 carrier:0
  8.           collisions:0 txqueuelen:1000
  9.           RX bytes:8568915 (8.1 MiB)  TX bytes:89469982 (85.3 MiB)
  10.           Interrupt:17 Base address:0xd800
  11.  
  12. eth1      Link encap:Ethernet  HWaddr 00:24:01:60:5f:00
  13.           inet addr:10.10.10.1  Bcast:10.10.10.255  Mask:255.255.255.0
  14.           inet6 addr: fe80::224:1ff:fe60:5f00/64 Scope:Link
  15.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  16.           RX packets:230 errors:0 dropped:0 overruns:0 frame:0
  17.           TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
  18.           collisions:0 txqueuelen:1000
  19.           RX bytes:30310 (29.5 KiB)  TX bytes:468 (468.0 B)
  20.           Interrupt:18 Base address:0xdc00
  21.  
  22. eth2      Link encap:Ethernet  HWaddr 00:24:01:d1:54:71
  23.           inet addr:10.10.20.1  Bcast:10.10.20.255  Mask:255.255.255.0
  24.           inet6 addr: fe80::224:1ff:fed1:5471/64 Scope:Link
  25.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  26.           RX packets:57096 errors:0 dropped:0 overruns:0 frame:0
  27.           TX packets:54137 errors:0 dropped:0 overruns:0 carrier:0
  28.           collisions:0 txqueuelen:1000
  29.           RX bytes:47262963 (45.0 MiB)  TX bytes:8481108 (8.0 MiB)
  30.           Interrupt:19 Base address:0xe000
  31.  
  32. lo        Link encap:Local Loopback
  33.           inet addr:127.0.0.1  Mask:255.0.0.0
  34.           inet6 addr: ::1/128 Scope:Host
  35.           UP LOOPBACK RUNNING  MTU:16436  Metric:1
  36.           RX packets:744 errors:0 dropped:0 overruns:0 frame:0
  37.           TX packets:744 errors:0 dropped:0 overruns:0 carrier:0
  38.           collisions:0 txqueuelen:0
  39.           RX bytes:130557 (127.4 KiB)  TX bytes:130557 (127.4 KiB)
  40.  
  41.  
  42. # Routing Gateway
  43.  
  44. /sbin/route add default gw 10.10.10.2 netmask 0.0.0.0 dev eth1
  45. /sbin/route add default gw 10.10.20.2 netmask 0.0.0.0 dev eth2
  46.  
  47. /usr/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 0/0 -j MASQUERADE
  48.  
  49. #Redirect Proxy 2005
  50. /usr/sbin/iptables -A PREROUTING -t nat -j REDIRECT -p tcp -s 192.168.0.0/24 -d 0/0 --dport 80 --to-ports 2005
  51.  
  52. /usr/sbin/iptables -A FORWARD -p tcp --dport 80 -i eth1 -s 192.168.0.254 -j DROP
  53. /usr/sbin/iptables -A FORWARD -p tcp --dport 80 -i eth2 -s 192.168.0.254 -j ACCEPT
  54.  
  55. /usr/sbin/iptables -A FORWARD -p tcp --dport 0:79 -i eth2 -s 192.168.0.254 -j DROP
  56. /usr/sbin/iptables -A FORWARD -p tcp --dport 0:79 -i eth1 -s 192.168.0.254 -j ACCEPT
  57.  
  58. /usr/sbin/iptables -A FORWARD -p tcp --dport 80:61000 -i eth2 -s 192.168.0.254 -j DROP
  59. /usr/sbin/iptables -A FORWARD -p tcp --dport 80:61000 -i eth1 -s 192.168.0.254 -j ACCEPT
  60.  
  61. /usr/sbin/iptables -A FORWARD -p tcp --dport 80 -i eth1 -d 10.10.10.2 -j REJECT
  62. /usr/sbin/iptables -A FORWARD -p tcp --dport 80 -i eth2 -d 10.10.20.2 -j ACCEPT
  63.  
  64. /usr/sbin/iptables -A INPUT -p tcp -s 192.168.0.254 -d 10.10.10.2 --dport 80 -j DROP
  65. /usr/sbin/iptables -A INPUT -p tcp -s 192.168.0.254 -d 10.10.20.2 --dport 80 -j ACCEPT