Sungjin's sub-brain :
Admin : New post
Guestbook
Local
Catergories
Recent Articles
Recent Comments
Calendar
Tag
Archive
Link
Search
 
해당되는 게시물 46건
  Packet Sniffering Program - Wireshark 
작성일시 : 2008. 5. 13. 16:29 | 분류 : 컴퓨터/Utilities

http://prdownloads.sourceforge.net/wireshark/wireshark-setup-1.0.0.exe

 

http://www.wireshark.org

About Wireshark

Wireshark is the world's foremost network protocol analyzer, and is the de facto (and often de jure) standard across many industries and educational institutions.

Wireshark development thrives thanks to the contributions of networking experts across the globe. It is the continuation of a project that started in 1998.

Features

Wireshark has a rich feature set which includes the following:

  • Deep inspection of hundreds of protocols, with more being added all the time
  • Live capture and offline analysis
  • Standard three-pane packet browser
  • Multi-platform: Runs on Windows, Linux, OS X, Solaris, FreeBSD, NetBSD, and many others
  • Captured network data can be browsed via a GUI, or via the TTY-mode TShark utility
  • The most powerful display filters in the industry
  • Rich VoIP analysis
  • Read/write many different capture file formats: tcpdump (libpcap), Catapult DCT2000, Cisco Secure IDS iplog, Microsoft Network Monitor, Network General Sniffer® (compressed and uncompressed), Sniffer® Pro, and NetXray®, Network Instruments Observer, Novell LANalyzer, RADCOM WAN/LAN Analyzer, Shomiti/Finisar Surveyor, Tektronix K12xx, Visual Networks Visual UpTime, WildPackets EtherPeek/TokenPeek/AiroPeek, and many others
  • Capture files compressed with gzip can be decompressed on the fly
  • Live data can be read from Ethernet, IEEE 802.11, PPP/HDLC, ATM, Bluetooth, USB, Token Ring, Frame Relay, FDDI, and others (depending on your platfrom)
  • Decryption support for many protocols, including IPsec, ISAKMP, Kerberos, SNMPv3, SSL/TLS, WEP, and WPA/WPA2
  • Coloring rules can be applied to the packet list for quick, intuitive analysis
  • Output can be exported to XML, PostScript®, CSV, or plain text
|
  gcc-3.2.3 과 systemc-2.1.v1의 조합 - compile 문제 
작성일시 : 2008. 2. 20. 17:22 | 분류 : 컴퓨터/LINUX

debian etch에 기본적으로 binutils2.17이 깔린데
그런데 이 버전에서 gcc-3.2.3을 이용해 systemc-2.1.v1을 컴파일 하고
컴파일 된 라이브러리를 이용해 systemc 어플리케이션을 컴파일 할 경우
"defined in discarded section" 블라블라 에러 메시지를 만날 수 있는데
이 문제는 binutils의 버전을 2.15로 낮추면 해결할 수 있다ㅠ

|
  Compile systemc 2-1.v1 with gcc-3.2.3 
작성일시 : 2008. 2. 20. 14:55 | 분류 : 컴퓨터/LINUX

새 머신에서 피코가 생성한 systemc 어플리케이션 컴파일이 안돼 gcc-3.2.3과 systemc를 다시 설치했다.

gcc-3.2.3은 ftp.gnu.org에서 소스를 받아와 debian 패키지의 gcc-3.3으로 컴파일을 하니
문제없이 컴파일 되었다.
컴파일 옵션은 ./configure --prefix=/opt/gcc-3.2.3 --program-suffix=-3.2.3 i686-pc-linux-gnu

gcc는 문제없이 성공한 후 systemc를 컴파일 했는데 문제가 발생했다.
오류 메시지는 다음과 같았다.
sungjin:/usr/src/systemc-2.1.v1# ./configure CC=/opt/gcc-3.2.3/bin/gcc-3.2.3  CXX=/opt/gcc-3.2.3/bin/g++-3.2.3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/usr/src/systemc-2.1.v1/config/missing: Unknown `--run' option
Try `/usr/src/systemc-2.1.v1/config/missing --help' for more information
configure: WARNING: `missing' script is too old or missing
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... /opt/gcc-3.2.3/bin/gcc-3.2.3
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /opt/gcc-3.2.3/bin/gcc-3.2.3 accepts -g... yes
checking for /opt/gcc-3.2.3/bin/gcc-3.2.3 option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of /opt/gcc-3.2.3/bin/gcc-3.2.3... gcc3
checking whether we are using the GNU C++ compiler... yes
checking whether /opt/gcc-3.2.3/bin/g++-3.2.3 accepts -g... yes
checking dependency style of /opt/gcc-3.2.3/bin/g++-3.2.3... gcc3
checking for ranlib... ranlib
checking for a BSD-compatible install... /usr/bin/install -c
configure: error: "sorry...compiler not supported"

왜왜왜왜왜? 안될까. 이해가 안돼 이것 저것 고민을 하다가 결국 해결책을 찾았는데 원인은 이상하게 만들어진 systemc의 configure 때문이었다. CC(=gcc-3.2.3)의 경우 gcc-3.2.3과 같이 실행 파일 뒤에 suffix가 붙어도 문제가 없었는데 CXX(=g++-3.2.3)의 경우 이름이 정확하게 g++이 아니면 configure: error: "sorry...compiler not supported"라는 어이없는 오류를 뱉어내는 것ㅠㅠ. 간단히 g++-3.2.3에 링크된 g++이란 심볼을 만들어 그 심볼을 실행 파일로 지정하니 문제없이 컴파일이 되었다.


|
  MAC 어드레스 바꾸기(리눅스) 
작성일시 : 2008. 2. 19. 13:23 | 분류 : 컴퓨터/LINUX

/etc/network/interfaces 를 다음과 같이 수정

iface eth0 inet static
address 192.168.0.111
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
hwaddress ether xx:xx:xx:xx:xx:xx
dns-nameservers 147.46.80.1



|
  호스트 머신에서 vmware로 ssh나 기타 어플리케이션의 접속 시간이 오래 걸릴 때 
작성일시 : 2008. 2. 19. 12:04 | 분류 : 컴퓨터/LINUX

비단 vmware에만 해당 되는건 아닌 듯 한데
이상하게 다른 서버에 접속하는 시간이 길어질 때...
(예를 들어 ssh로 접속을 하는데 패스워드를 묻는데 까지 10초가 걸린다거나 하는?)
dns의 문제일 가능성이 있다. 해우형의 말론 reverse dns lookup이라던가?
이런 경우 호스트와 vmware상의 머신의
/etc/hosts에 상대 머신의 아이피와 hostname을 적어두면
상태가 나아질 수 있다.
|
  Free Proxy Server daemon - FreeProxy 
작성일시 : 2008. 1. 10. 00:55 | 분류 : 컴퓨터/Utilities


http://www.handcraftedsoftware.org/

FreeProxy Internet Suite V4.00 now available
FreeProxy Internet Suite V4.00 now available FreeProxy Internet Suite V4.00 now available
FreeProxy V4.00 has been renamed to the FreeProxy Internet Suite with the addition of full featured SMTP and POP server functionality. In addition to the current PROXY functions of HTTP, Socks etc, and in addition to the current Web server, SMTP and POP has been added. SMTP and POP will enable you to set up your own inbound and outbound mail system with local mail retrieval.
Version 4.00 is currently available as an Alpha version as it has a lot of new functionality. Existing functionality will continue to exist. So potentially you can launch FIS to run a HTTP proxy, a Web Server, a POP server, a SMTP server (and others) all at the same time.

I have tested the following FREE portals with FIS V4.00.
Mambo, phpBB, Joomla and Drupal. All work perfectly with the web server and ISAPI plugin. There is now a howto in the KB explaining how to set up your own portal based on FIS.

So FIS is a complete internet tool with both a good range of proxies and internet services.
|
  Free Proxy Server daemon - AnalogX 
작성일시 : 2008. 1. 10. 00:53 | 분류 : 컴퓨터/Utilities



Proxy    (click here to download)  v4.14 269k
blank

Proxy Screenshot
    Do you have several machines on a network, but only one connection to the internet? Wish you could browse the net from the other machines, just like you can from the machine that's connected? Then what you're looking for is called a Proxy Server, and AnalogX has just what you want. AnalogX Proxy is a small and simple server that allows any other machine on your local network to route it's requests through a central machine. So what does that mean in English? Simple, run Proxy on the machine with the internet connection; configure the other machines to use a proxy (it's very easy, there's a detailed description in the readme), and voila! You're surfing the web from any other machine on your network! Supports HTTP (web), HTTPS (secure web), POP3 (recieve mail), SMTP (send mail), NNTP (newsgroups), FTP (file transfer), and Socks4/4a and partial Socks5 (no UDP) protocols! It works great with Internet Explorer, Netscape, AOL, AOL Instant Messenger, Microsoft Messenger, and many more!

|
  TCP/IP Packet Sniffer - smsniff 
작성일시 : 2008. 1. 10. 00:50 | 분류 : 컴퓨터/Utilities



http://www.nirsoft.net/utils/smsniff.html


SmartSniff v1.35 - Freeware TCP/IP Packet Sniffer
Copyright (c) 2004 - 2007 Nir Sofer

Description

SmartSniff allows you to capture TCP/IP packets that pass through your network adapter, and view the captured data as sequence of conversations between clients and servers. You can view the TCP/IP conversations in Ascii mode (for text-based protocols, like HTTP, SMTP, POP3 and FTP.) or as hex dump. (for non-text base protocols, like DNS)
SmartSniff provides 3 methods for capturing TCP/IP packets :
  1. Raw Sockets (Only for Windows 2000/XP or greater): Allows you to capture TCP/IP packets on your network without installing a capture driver. This method has some limitations and problems.
  2. WinPcap Capture Driver: Allows you to capture TCP/IP packets on all Windows operating systems. (Windows 98/ME/NT/2000/XP/2003/Vista) In order to use it, you have to download and install WinPcap Capture Driver from this Web site. (WinPcap is a free open-source capture driver.)
    This method is generally the preferred way to capture TCP/IP packets with SmartSniff, and it works better than the Raw Sockets method.
  3. Microsoft Network Monitor Driver (Only for Windows 2000/XP/2003): Microsoft provides a free capture driver under Windows 2000/XP/2003 that can be used by SmartSniff, but this driver is not installed by default, and you have to manually install it, by using one of the following options:
    Notice: If WinPcap is installed on your system, and you want to use the Microsoft Network Monitor Driver method, it's recommended to run SmartSniff with /NoCapDriver, because the Microsoft Network Monitor Driver may not work properly when WinPcap is loaded too.

System Requirements

SmartSniff can capture TCP/IP packets on any 32-bit Windows operating system (Windows 98/ME/NT/2000/XP) as long as WinPcap capture driver is installed and works properly with your network adapter.
Under Windows 2000/XP (or greater), SmartSniff also allows you to capture TCP/IP packets without installing any capture driver, by using 'Raw Sockets' method. However, this capture method has some limitations and problems:
  • Outgoing UDP and ICMP packets are not captured.
  • On Windows XP SP1 outgoing packets are not captured at all - Thanks to Microsoft's bug that appeared in SP1 update...
    This bug was fixed on SP2 update, but under Vista, Microsoft returned back the outgoing packets bug of XP/SP1.

Versions History

  • Version 1.35:
    • New Display Mode - 'URL List': Allows you to view the list of URLs for the select TCP/IP items (only for HTTP protocol)
    • Increased the buffer of raw sockets to avoid packet loss.
    • The configuration is now saved to a file, instead of the Registry.
  • Version 1.32:
    • Fixed bug: Wrong capture time displayed when "Only display TCP/IP statistic..." option was selected.
    • Added 'Summary Mode' in Advanced Options - Allows you to view general TCP/IP statistics by addresses only, without adding a separated line for each connection.
  • Version 1.31:
    • Added support for Microsoft Network Monitor driver (Under Windows 2000/XP/2003).
  • Version 1.30:
    • New option: Only display TCP/IP statistic, do not store the captured data in file.
    • New option: Retrieve process information while capturing packets.
    • In 'Load Packets Data From File', you can now choose to load tcpdump/libpcap file saved by Ethereal or by other capture programs.
    • A tooltip is displayed when a string in a column is longer than the column length.
    • When running SmartSniff in the first time, the first found network adapter with IP address is now automatically selected. (In previous versions, the user had to select an adapter in order to start capturing)
  • Version 1.21:
    • Fixed Bug: packets in TCP/IP conversations sometimes displayed in wrong order.
  • Version 1.20:
    • New option in Live Mode: Display the beginning of TCP/IP conversation content while capturing.
    • Save / Load SmartSniff configuration.
    • Filters are now saved when you exit from SmartSniff, and loaded again in the next time that you run it.
    • Significant improvement in performances of Live Mode when there are a lots of TCP/IP conversations.
    • Fixed bug: pressing F2/F3/F4 while capturing packets in live mode caused the capture to be corrupted.
  • Version 1.11: Improve in performances while capturing with WinPcap driver.
  • Version 1.10:
    • Performances - Large TCP/IP conversations are now displayed much faster than in previous version.
    • Live Mode - View the TCP/IP conversation list while capturing.
    • Capture and display filters.
    • New option: Resolve IP Addresses to host names (displayed in 'Local Host' and 'Remote Host' columns)
    • New option: On Automatic display mode, don't display data in hex format if the data size is larger than... (The default is 100 KB)
    • New option: In the lower pane, don't display items with data size larger than... (The default is 1000 KB)
    • Added more accelerator keys.
    • XP style support.
  • Version 1.00: First release.

Using SmartSniff

In order to start using SmartSniff, simply copy the executable (smsniff.exe) to any folder you like, and run it (installation is not needed).
After running SmartSniff, select "Start Capture" from the File menu, or simply click the green play button in the toolbar. If it's the first time that you use SmartSniff, you'll be asked to select the capture method and the network adapter that you want to use. If WinPcap is installed on your computer, it's recommended to use this method to capture packets.
After selecting the capture method and your network adapter, click the 'OK' button to start capturing TCP/IP packets. while capturing packets, try to browse some Web sites, or retrieve new emails from your email software. After stopping the capture (by clicking the red stop button) SmartSniff displays the list of all TCP/IP conversations the it captured. When you select a specific conversation in the upper pane, the lower pane displays the TCP/IP streams of the selected client-server conversation.

If you want the save the captured packets for viewing them later, use "Save Packets Data To File" option from the File menu.

Display Mode

SmartSniff provides 3 basic modes to display the captured data: Automatic, Ascii, and Hex Dump. On Automatic mode (the default), SmartSniff checks the first bytes of the data stream - If it contains characters lower than 0x20 (excluding CR, LF and tab characters), it displays the data in Hex mode. otherwise, it displays it in Ascii mode.
You can easily switch between display modes by selecting them from the menu, or by using F2 - F4 keys. Be aware that 'Hex Dump' mode is much slower than Ascii mode.

Starting from version 1.35, there is a new mode - 'URL List'. This mode only display the URL addresses list (http://...) found in the captured packets.

Exporting the captured data

SmartSniff allows you to easily export the captured data for using it in other applications:
  • The upper pane: you can select one or more items in the upper pane, and then copy them to the clipboard (You can paste the copied items into Excel or into spreadsheet of OpenOffice.org) or save them to text/HTML/XML file (by using 'Save Packet Summaries').
  • The lower pane: You can select any part of the TCP/IP streams (or select all text, by using Ctrl+A), copy the selected text to the clipboard, and then paste it to Notepad, Wordpad, MS-Word or any other editor. When you paste the selected streams to document of Wordpad, OpenOffice.org, or MS-Word, the colors are also transferred.
    Your can also export the TCP/IP streams to text file, HTML file, or raw data file, by using "Export TCP/IP Streams" option.

Displaying characters above ASCII 127

By default, characters above ASCII 127 are not displayed in the TCP/IP streams. You can enable high ASCII characters by using "Display Characters Above ASCII 127". When you use this option, the TCP/IP streams are displayed without colors. Be aware that when working in this mode, the loading process of the lower pane might be very slow.

Capture and Display Filters

Starting from version 1.10, you can filter unwanted TCP/IP activity during the capture process (Capture Filter), or when displaying the captured TCP/IP data (Display Filter).

For both filter types, you can add one or more filter strings (separated by spaces or CRLF) in the following syntax:
[include | exclude] : [local | remote | both] : [tcp | udp | tcpudp | icmp | all] : [IP Range | Ports Range]

Here's some examples that demonstrate how to create a filter string:

  • Display only packets with remote tcp port 80 (Web sites):
    include:remote:tcp:80
  • Display only packets with remote tcp port 80 (Web sites) and udp port 53 (DNS):
    include:remote:tcp:80
    include:remote:udp:53
  • Display only packets originated from the following IP address range: 192.168.0.1 192.168.0.100:
    include:remote:all:192.168.0.1-192.168.0.100
  • Display only TCP and UDP packets that use the following port range: 53 - 139:
    include:both:tcpudp:53-139
  • Filter most BitTorrent packets (port 6881):
    exclude:both:tcpupd:6881
  • Filter all ICMP packets (Ping/Traceroute activity):
    exclude:both:icmp
Notice: A single filter string must not include spaces !

Live Mode

Starting from version 1.10, a new option was added to 'Advanced Options' section - 'Live Mode'. When SmartSniff capture packets in live mode, the TCP/IP conversations list is updated while capturing the packets, instead of updating it only after the capture is finished. Be aware that "Live Mode" requires more CPU resources than non-live mode. So if your computer is slow, or your have a very high traffic on your network, it's recommended to turn off this option.
Starting from version 1.20, you can also view the content of each TCP/IP conversation (in the lower pane) while capturing the packets. However, if the TCP/IP conversation is too large, you won't be able to watch the entire TCP/IP conversation until the capture is stopped.

Viewing process information

Starting from version 1.30, you can view the process information (ProcessID and process filename) for captured TCP packets. However, this feature have some limitations and problems:
  • Process information is only displayed for TCP packets (It doesn't work with UDP)
  • Process information may not be displayed for TCP connections that closed after short period of time.
  • Retrieving process information consume more CPU resources and may slow down your computer. It's not recommended to use this feature if you have intensive network traffic.
  • Process information is currently not saved in ssp file.
In order to activate this feature, go to 'Advanced Options' dialog-box, check the "Retrieve process information while capturing packets" option and click the 'OK' button. 2 new columns will be added: ProcessID and Process Filename. Start capturing, and process information will be displayed for the captured TCP conversations.

Translating to other languages

SmartSniff allows you to easily translate all dialog-boxes, menus, and strings to other language.
In order to do that, follow the instructions below:
  1. Run SmartSniff with /savelangfile parameter:
    smsniff.exe /savelangfile
    A file named smsniff_lng.ini will be created in the folder of SmartSniff utility.
  2. Open the created language file in Notepad or in any other text editor.
  3. Translate all menus, dialog-boxes, and string entries to the desired language.
  4. After you finish the translation, Run SmartSniff, and all translated strings will be loaded from the language file.
    If you want to run SmartSniff without the translation, simply rename the language file, or move it to another folder.

Command-Line Options

Command Description
/NoCapDriver Starts SmartSniff without loading the WinPcap Capture Driver.
/NoLoadSettings Starts SmartSniff without loading your last settings.

License

This utility is released as freeware. You are allowed to freely distribute this utility via floppy disk, CD-ROM, Internet, or in any other way, as long as you don't charge anything for this. If you distribute this utility, you must include all files in the distribution package, without any modification !

Disclaimer

The software is provided "AS IS" without any warranty, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The author will not be liable for any special, incidental, consequential or indirect damages due to loss of data or any other reason.

Feedback

If you have any problem, suggestion, comment, or you found a bug in my utility, you can send a message to nirsofer@yahoo.com

Download SmartSniff (In ZIP file)
Download self-install executable for installing SmartSniff with uninstall support

SmartSniff is also available in other languages. In order to change the language of SmartSniff, download the appropriate language zip file, extract the 'smsniff_lng.ini', and put it in the same folder that you Installed SmartSniff utility.

Language Translated By Version
Italian Marco D'Amato 1.32
Polish wins 1.21
Spanish   1.30
Traditional Chinese qq123 1.00
Galician Xos Antn Vicente Rodrguez
http://www.iespana.es/engalego
http://engalego.blogspot.com
1.00
Dutch Bob Loeffen 1.00
Korean KIM JaeGeun 1.21
French int24h 1.11
Czech http://www.martinkozak.czweb.org/ 1.11
German Latino 1.32
Simplified Chinese Renda 1.35
Traditional Chinese Eros 1.21
Taiwanese Eros 1.21
Arabic Ahmad Al-Hourani 1.30
Russian solokot 1.32

|
  윈도우용 이메일(pop3, smtp) 서버 - hMailServer 
작성일시 : 2008. 1. 10. 00:47 | 분류 : 컴퓨터/Utilities



http://www.hmailserver.com/


hMailServer is a free e-mail server for Microsoft Windows. It supports all the common e-mail protocols (IMAP, SMTP and POP3) and comes with an easy-to-use COM library that can be used for integration with other software. It also has support for virtual domains, distribution lists, antivirus, antispam, aliases, distributed domains and much more. E-mail data is stored in a database server, MySQL or MS SQL, depending on your choice.

The hMailServer installation contains a minimal MySQL-installation, so if you don't already have a database server in your network, MySQL is installed automatically when you install hMailServer.

 


hMailServer Administrator

|
  iptables를 이용한 포트 포워딩 
작성일시 : 2008. 1. 3. 15:37 | 분류 : 컴퓨터/LINUX

간단히

Source: xxx.xxx.xxx.xxx:80 -- forwarded to -> 192.168.0.2:80

You can chhose any port on xxx.xxx.xxx.xxx it need not match the port we are forwarding to.

Source: xxx.xxx.xxx.xxx:8888 -- forwarded to -> 192.168.0.2:80

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d xxx.xxx.xxx.xxx
--dport 8888 -j DNAT --to 192.168.0.2:80
/sbin/iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.2 --dport 80 -j ACCEPT







PORT FORWARDING - with IPTABLES while using BASTILLE firewall

Background on network setup

I have my home network setup as described here. So my linux gateway server is the only one visible to the internet, while all other machines are in an internal subnet with DHCP assigned IP's not visible to the outside internet, but can access the outside net using Iptables based Network Address Translation (NAT).

Why you need portforwarding

So in this setup if I want to run a public service like httpd, not on the gateway server ( where it is visible to outside ) but on an internal machine ( which is not visible outside ) how do I make it availble to the outside internet.

To make the above scenario of exposing and internal machine's service to outside we need to use port forwarding on the gateway server. Which is assigning a port on the gateway to accept all connections and forward it to the internal machines port where the service is listening to.

Let xxx.xxx.xxx.xxx be the IP address of the gateway server connected to the cable modem and 192.168.0.2 , the IP address of the internal machine. And say we want to run a web server ( httpd ) on 192,168.0.2 on port 80 which should be avaialble to the outside internet. We can forward the port 80 on xxx.xxx.xxx.xxx to port 80 of 192.168.0.2

Source: xxx.xxx.xxx.xxx:80 -- forwarded to -> 192.168.0.2:80

You can chhose any port on xxx.xxx.xxx.xxx it need not match the port we are forwarding to.

Source: xxx.xxx.xxx.xxx:8888 -- forwarded to -> 192.168.0.2:80

Port Forwarding using Iptables

Since I have been using 2.4 kernel, I use iptables for firewall and NAT. So these are the Iptable rules required for port forwarding xxx.xxx.xxx.xxx:8888 to 192.168.0.2:80 .

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d xxx.xxx.xxx.xxx
		 --dport 8888 -j DNAT --to 192.168.0.2:80
/sbin/iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.2 --dport 80 -j ACCEPT

How to add custom rules to Bastille firewall

Since I trust Bastille firwall script to generate the correct iptable scripts for my server, I wanted to keep those scripts but add these custom port forwarding rules to supplement/extend it.

But the version of Bastille on my machine ( 1.2.0 ) does not support port forwarding, and does not had a way of adding custom scripts to it. Posting the question to Bastille mailing list generated these prompt responses from Peter Watkins, core developer of Bastille. ( See the complete thread )

Following Peter's advice I upgraded Bastille to the latest version, without any problem. The new version regenerated all the scripts with my old rules intact.

And with the new Bastill in place and working fine doing all the firewall filteringa nd NAT. I made the following changes to add a supplemental script, portforward.sh ( get the script ) for my custom port forwarding rules.

Created the directories for supplemetal script. ( as explained in the comments at portforward.sh )

/etc/Bastille/firewall.d/pre-chain-split.d/

Created portforward.sh with working portforwarding rules, following the sample script from Peter.
[ Please note: The ipchains rules in portforward.sh are untested. I have left it there from Peter's sample script for completeness. ]

In portforward.sh all you have to do is specify the portforwarding source and destination IP addresses and ports with the ethernet interface name ( "eth0" if you have only one interface ) and the protocol type ( "tcp" in this case ).

IP_FORWARDS="eth0-xxx.xxx.xxx.xxx-8888-tcp-192.168.0.2-80"

Also you can have multiple port forwaring specified like:

IP_FORWARDS="eth0-xxx.xxx.xxx.xxx-8888-tcp-192.168.0.2-80 
		eth0-xxx.xxx.xxx.xxx-2222-tcp-192.168.0.2-22"

This will be parsed and stored into varibles down the script and used in the following Iptable calls to generate the rules. [ NOTE: The rules need to be on a single continuous line, I have broken it down to two lines for readability ]

${IPTABLES} -t nat -A PREROUTING -p $fw_inproto -i $fw_iface 
   -d $fw_inaddr --dport $fw_inport -j DNAT --to $fw_outaddr:$fw_outport

${IPTABLES} -A FORWARD -p $fw_inproto -i $fw_iface 
   -d $fw_outaddr --dport $fw_outport -j ACCEPT

Which will translate to.

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d xxx.xxx.xxx.xxx 
	--dport 8888 -j DNAT --to 192.168.0.2:80
/sbin/iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.2 
   	--dport 80 -j ACCEPT

Now we can restart Bastille scripts to make this rules effective.

#/etc/rc.d/init.d/bastille-firewall start

Verify the rules by listing them.

# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source   destination
DNAT   tcp  --  anywhere xxx.xxx.xxx.xxxtcp dpt:ddi-tcp-1 to:192.168.0.2:80

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  192.168.0.0/16       anywhere
MASQUERADE  all  --  192.168.0.0/16       anywhere
MASQUERADE  all  --  192.168.0.0/16       anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
#
[ where "ddi-tcp-1", I assume corresponds to port 8888 ]

Verify the port forwaring works by connecting to the port from a machine outside the network.

Notes on this setup

The above rules work fine when you access from outside, but if you try to access the same port xxx.xxx.xxx.xxx:8888 from an internal machine, it will not work. But from the internal network you dont need the forwarding, since you can directly access the machine 192.168.0.2:80.



Friday, 20-Aug-2004 09:42:03 PDT kishan at hackorama dot com
|
 Prev   1   2   3   4   5   Next