<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Just a reference base &#187; debian</title>
	<atom:link href="http://www.troublenow.org/archives/category/linux/debian/feed" rel="self" type="application/rss+xml" />
	<link>http://www.troublenow.org</link>
	<description>Just a reference base</description>
	<lastBuildDate>Thu, 08 Jul 2010 12:52:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mobile internet using you mobile phone in Linux</title>
		<link>http://www.troublenow.org/archives/22</link>
		<comments>http://www.troublenow.org/archives/22#comments</comments>
		<pubDate>Sun, 24 Aug 2008 16:22:20 +0000</pubDate>
		<dc:creator>Arno Haverlach</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.troublenow.org/?p=22</guid>
		<description><![CDATA[When I am on the road sometimes its very handy to have internet around.
luckily this is very easy to accomplish in Linux. In this case I will be using a Samsung F700 Mobile phone connected to my Asus EEE 701 laptop running Ubuntu linux.
A few things however to think of before you start:
- Do you [...]]]></description>
			<content:encoded><![CDATA[<p>When I am on the road sometimes its very handy to have internet around.</p>
<p>luckily this is very easy to accomplish in Linux. In this case I will be using a Samsung F700 Mobile phone connected to my Asus EEE 701 laptop running Ubuntu linux.</p>
<p>A few things however to think of before you start:<br />
- Do you have a &#8216;unlimited&#8217; or limited (100MiB/1GiB etc..) contract (&#8216;unlimited&#8217; is recommended)<br />
- Does your provider allow dial up using your phone &amp; laptop (By Vodafone it is not allowed but if you use it for &#8216;normal&#8217; web browsing they don&#8217;t mind (if you start using it to download your latest TV episode&#8217;s or whatever you will be shutdown.)</p>
<p><strong>So lets start:</strong></p>
<p>First connect the phone to the laptop using the USB cable in my case the phone will ask me in what &#8216;mode&#8217; the phone should operate, I need to select &#8216;pc studio&#8217; to use the phone as a gateway to the internet.</p>
<p>Now when the phone is connected to the PC open a terminal and run wvdialconf to create a new config file:</p>

<div class="wp-terminal">trouble@sun:$ sudo wvdialconf /etc/wvdial.conf<br/><br/>Editing `/etc/wvdial.conf'.<br/><br/>Scanning your serial ports for a modem.<br/><br/>ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud<br/>ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud<br/>ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- and failed too at 115200, giving up.<br/>Modem Port Scan&lt;*1&gt;: S1   S2   S3<br/>WvModem&lt;*1&gt;: Cannot get information for serial port.<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 -- OK<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 Z -- OK<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 -- OK<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 -- OK<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 -- OK<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 +FCLASS=0 -- ERROR<br/>ttyACM0&lt;*1&gt;: Modem Identifier: ATI -- Manufacturer: SAMSUNG ELECTRONICS CORPORATION<br/>ttyACM0&lt;*1&gt;: Speed 4800: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 9600: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 19200: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 38400: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 57600: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 115200: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 230400: AT -- OK<br/>ttyACM0&lt;*1&gt;: Speed 460800: AT -- OK<br/>ttyACM0&lt;*1&gt;: Max speed is 460800; that should be safe.<br/>ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 -- OK<br/><br/>Found an USB modem on /dev/ttyACM0.<br/>Modem configuration written to /etc/wvdial.conf.<br/>ttyACM0: Speed 460800; init "ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2"<br/></div>

<p>As you can see it found my Samsung F700 phone and updated the wvdial.conf file.</p>
<p>Now we need to edit the wvdial.conf file to add a few paramaters (user/pass &amp; dial number)<br />
the default config file looks like this:</p>

<div class="wp-terminal">trouble@sun:$ $ cat /etc/wvdial.conf<br/><br/>[Dialer Defaults]<br/>Init1 = ATZ<br/>Init2 = ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2<br/>Modem Type = USB Modem<br/>Baud = 460800<br/>New PPPD = yes<br/>Modem = /dev/ttyACM0<br/>ISDN = 0<br/>; Phone =<br/>; Password =<br/>; Username =<br/></div>

<p>Now you will need to know the &#8216;Target Phone Number&#8217; for vodafone in the Netherlands this is &#8216;*99#&#8217; but this might be different in your case so just &#8216;google&#8217; around if you have a other provider for the target phone number.</p>
<p>The username and password can be just random but I like to keep it simple and changed both to &#8216;vodafone&#8217;</p>
<p>Also you need to enable &#8217;stupid mode&#8217; in wvdial to work around some of the &#8216;intelligence&#8217; in wvdial to get it to work.</p>
<p>So vi the wvdial.conf file and it should look like this:</p>

<div class="wp-terminal">trouble@sun:$ $ sudo vi /etc/wvdial.conf<br/>[Dialer Defaults]<br/>Init1 = ATZ<br/>Init2 = ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2<br/>Modem Type = USB Modem<br/>Baud = 460800<br/>New PPPD = yes<br/>Modem = /dev/ttyACM0<br/>ISDN = 0<br/>Phone = *99#<br/>Password = vodafone<br/>Username = vodafone<br/>Stupid Mode = 1<br/></div>

<p>Now you are ready to go, so start &#8216;wvdial&#8217; and you should be connected (I created a desktop terminal launcher with the command: &#8217;sudo wvdial&#8217; for this).</p>

<div class="wp-terminal">trouble@sun:$ $ sudo wvdial<br/>--&gt; WvDial: Internet dialer version 1.60<br/>--&gt; Cannot get information for serial port.<br/>--&gt; Initializing modem.<br/>--&gt; Sending: ATZ<br/>ATZ<br/>OK<br/>--&gt; Sending: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2<br/>ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2<br/>OK<br/>--&gt; Modem initialized.<br/>--&gt; Sending: ATDT*99#<br/>--&gt; Waiting for carrier.<br/>ATDT*99#<br/>CONNECT<br/>--&gt; Carrier detected.  Starting PPP immediately.<br/>--&gt; Starting pppd at Sun Aug 24 18:14:11 2008<br/>--&gt; Pid of pppd: 23198<br/>--&gt; Using interface ppp0<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; local  IP address YOURIP<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; remote IP address GATEWAYIP<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; primary   DNS address DNSIP<br/>--&gt; pppd: ��[06][08]��[06][08]<br/>--&gt; secondary DNS address DNSIP<br/>--&gt; pppd: ��[06][08]��[06][08]<br/></div>

]]></content:encoded>
			<wfw:commentRss>http://www.troublenow.org/archives/22/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burning a video DVD VIDEO_TS in Linux</title>
		<link>http://www.troublenow.org/archives/20</link>
		<comments>http://www.troublenow.org/archives/20#comments</comments>
		<pubDate>Tue, 15 Jan 2008 18:01:59 +0000</pubDate>
		<dc:creator>Arno Haverlach</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.troublenow.org/?p=20</guid>
		<description><![CDATA[You can rip dvd&#8217;s with multiple tools, and some of these rip the dvd to a &#8216;VIDEO_TS&#8217; and &#8216;AUDIO_TS&#8217; folder. You can burn them again with the tool mkisofs.
Place your &#8216;VIDEO_TS&#8217; and &#8216;AUDIO_TS&#8217; in a folder (lets say /home/user1/mymovie/)
Install mkisofs:

trouble@sun:$ apt-get updatetrouble@sun:$ apt-get install mkisofs

Then use mkisofs to create a ISO file from the folder:

trouble@sun:$ [...]]]></description>
			<content:encoded><![CDATA[<p>You can rip dvd&#8217;s with multiple tools, and some of these rip the dvd to a &#8216;VIDEO_TS&#8217; and &#8216;AUDIO_TS&#8217; folder. You can burn them again with the tool mkisofs.</p>
<p>Place your &#8216;VIDEO_TS&#8217; and &#8216;AUDIO_TS&#8217; in a folder (lets say /home/user1/mymovie/)</p>
<p>Install mkisofs:</p>

<div class="wp-terminal">trouble@sun:$ apt-get update<br/>trouble@sun:$ apt-get install mkisofs<br/></div>

<p>Then use mkisofs to create a ISO file from the folder:</p>

<div class="wp-terminal">trouble@sun:$ mkisofs -dvd-video -o /home/user1/mymovie.iso /home/user1/mymovie/<br/></div>

<p>Now in /home/user1 you have a iso file called &#8216;mymovie.iso&#8217;</p>
<p>now use brazero or any other burning tool to burn the .iso file to a DVD.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.troublenow.org/archives/20/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firewall VMware Server 1.0.x guest with iptables on the host</title>
		<link>http://www.troublenow.org/archives/19</link>
		<comments>http://www.troublenow.org/archives/19#comments</comments>
		<pubDate>Thu, 06 Dec 2007 12:33:07 +0000</pubDate>
		<dc:creator>Arno Haverlach</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.troublenow.org/?p=19</guid>
		<description><![CDATA[Running a linux host with VMware 1.0.x Server you are not able to firewall the VMware guests on the host machine. Because vmware runs in the kernel the traffic to the guest is already handled by vmware before iptables will see the traffic.
Now it is possible to firewall the client by setting up a dummy [...]]]></description>
			<content:encoded><![CDATA[<p>Running a linux host with VMware 1.0.x Server you are not able to firewall the VMware guests on the host machine. Because vmware runs in the kernel the traffic to the guest is already handled by vmware before iptables will see the traffic.</p>
<p>Now it is possible to firewall the client by setting up a dummy network interface and bridge the physical interface to the dummy, this way you can let VMware setup his bridge to the dummy interface and you see the traffic passing by.</p>
<p><strong>The layout</strong></p>
<p>Lets say you have the following setup (click for larger):<br />
<a href="http://www.troublenow.org/crap/pics/vmware/networklayout.png" target="_blank"><img src="http://www.troublenow.org/crap/pics/vmware/networklayout.png" height="200" width="500" alt="network layout"/></a></p>
<p>host01 has a virtual host &#8216;guest01&#8242; and it is bridged to eth0 and eth1 so it has a connection to the internet and a connection to the backlan to reach the DB0x servers.</p>
<p>However host02 has the same setup, but I don&#8217;t want &#8216;guest02&#8242; to reach &#8216;guest01&#8242;, this could be aranged with a firewall on the guests but thats a bad solution if they are running windows (you don&#8217;t want to overload a already bloated windows with a extra firewall right?), so however there are multiple ways to fix this one solution is to setup a bridge on the host machine&#8217;s and firewall the traffic before it reaches the guest.</p>
<p>The following image should explain it a little more (click for larger):<br />
<a href="http://www.troublenow.org/crap/pics/vmware/logical-bridge.png" target="_blank"><img src="http://www.troublenow.org/crap/pics/vmware/logical-bridge.png" height="200" width="500" alt="logical bridge"/></a></p>
<p><strong>The configuration</strong></p>
<p>In this setup the &#8216;host&#8217; machine is running ubuntu 6.06.1 LTS, has 2 nic&#8217;s and we are using VMware Server 1.0.4. that should have a bridge to both nics.<br />
We will be creating 2 dummy network interfaces called &#8216;dummy0&#8242; and &#8216;dummy1&#8242; and 2 bridges called &#8216;br0&#8242; and &#8216;br1&#8242;.<br />
Then bind eth0 to dummy0 with br0 and eth1 to dummy1 with br1.</p>
<p>First install bridge utilities</p>

<div class="wp-terminal">trouble@sun:$ apt-get install bridge-utils<br/></div>

<p>Now connect to the console of the server as you can&#8217;t do this remote (well you can but then do 1 interface at a time)<br />
Shutdown vmware and shutdown the interfaces</p>

<div class="wp-terminal">trouble@sun:$ /etc/init.d/vmware stop<br/>trouble@sun:$ ifdown eth0<br/>trouble@sun:$ ifdown eth1<br/></div>

<p>Now be sure to comment out the settings in /etc/network/interfaces for eth0 and eth1 so these are not read anymore.</p>
<p>create the dummy interfaces</p>

<div class="wp-terminal">trouble@sun:$ modprobe dummy -o dummy0<br/>trouble@sun:$ modprobe dummy -o dummy1<br/></div>

<p>then create bridge 0 and bridge 1 and bind the interfaces to them, in my network I need to put stp &#8216;off&#8217; but check in your case.</p>
<p># br0, eth0 and dummy0</p>

<div class="wp-terminal">trouble@sun:$ brctl addbr br0<br/>trouble@sun:$ brctl addif br0 eth0<br/>trouble@sun:$ brctl addif br0 dummy0<br/>trouble@sun:$ brctl stp br0 off<br/></div>

<p># br1, eth1 and dummy1</p>

<div class="wp-terminal">trouble@sun:$ brctl addbr br1<br/>trouble@sun:$ brctl addif br1 eth1<br/>trouble@sun:$ brctl addif br1 dummy1<br/>trouble@sun:$ brctl stp br1 off<br/></div>

<p>Now with the command &#8216;brctl show&#8217; you should see the interfaces.</p>

<div class="wp-terminal">trouble@sun:$ brctl show<br/>bridge name     bridge id               STP enabled     interfaces<br/>br1             8000.00112f164152       no              eth1<br/>dummy1<br/>br0             8000.00112f164151       no              eth0<br/>dummy0<br/></div>

<p>Oke now the bridges are configured, time to add a ipaddress to br0 and br1 so we can also connect to the server for management. Currently I will do this with ifconfig instead of putting it in the network file (see below for the complete script)</p>

<div class="wp-terminal">trouble@sun:$ ifconfig eth0 0.0.0.0<br/>trouble@sun:$ ifconfig dummy0 0.0.0.0<br/>trouble@sun:$ ifconfig eth1 0.0.0.0<br/>trouble@sun:$ ifconfig dummy1 0.0.0.0<br/>trouble@sun:$ ifconfig br0 10.1.1.2 netmask 255.255.255.0<br/>trouble@sun:$ ifconfig br1 192.168.10.2 netmask 255.255.255.0<br/>trouble@sun:$ route add default gw 10.1.1.1<br/></div>

<p>Now the host should be reachable again on his network interfaces.</p>
<p>Now its time to reconfigure VMware with  vmware-config.pl, when it asks for the network settings change them in the &#8216;editor&#8217; mode and set bridging on &#8216;vmnet0&#8242; to &#8216;br0&#8242; and &#8216;vmnet2&#8242; to &#8216;br1&#8242;.<br />
Edit your virtual machine to use vmnet0 and vmnet2 and you should be ready to go with network on the virtual machines again.</p>
<p><strong>The Firewall Rules</strong></p>
<p>So the bridges are set, now its time to create some firewall rules, I won&#8217;t start explaining iptables here so here is an example configuration script that creates the bridged interfaces and configures the firewall.</p>
<p>To explain it a little:<br />
First I will create the bridges and add ipaddresses to them, and only do this if they are not already created.<br />
Then we move all traffic flowing through br0 in &#8216;Aforward&#8217; (traffic to dummy0), and all traffic flowing through br1 in &#8216;Bforward&#8217; (traffic to dummy1)(Just give it your own names if you wish this is logical for me <img src='http://www.troublenow.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now make sure to put your firewall rules for the guests in the section marked as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">##### Firewall rules for br0 from here! ####  </span>
   <span style="color: #666666; font-style: italic;">##### Firewall rules for br0 until here! ####</span></pre></td></tr></table></div>

<p>And the same for br1, and configure your local firewall rules to the ipaddresses of the host in:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#-------- Local Firewall Rules to this host ----------#</span>
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span></pre></td></tr></table></div>

<p>And you should be ready to go firewalled all traffic flowing through the vmware guests. Be sure to understand that this will only firewall the traffic from the &#8216;outside&#8217; to your guest if you have multiple guests on your vmware host traffic is not firewalled between the 2 guests. This could be fixed by putting every guest in a seperate vmnet and use the host to NAT traffic to it but that won&#8217;t work in every setup.<br />
Currently in the setup I am using I only have 2 Windows servers on 2 different hosts so I bridged those, firewalled those on the hosts, and the linux guests on the same hosts have there own firewall rules so I don&#8217;t have this problem. (you do firewall all your nodes in a network right?)</p>
<p>And the complete script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#----------------------------------------------------#</span>
<span style="color: #666666; font-style: italic;">#   Arno Haverlach (arno (at) haverlach (dot) nl)</span>
<span style="color: #666666; font-style: italic;">#   Firewall/Bridge script for vmware</span>
<span style="color: #666666; font-style: italic;">#   ver 0.1 20071204</span>
<span style="color: #666666; font-style: italic;">#----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#--------------IP Variables -------------------------#</span>
<span style="color: #007800;">DNS1</span>=10.1.1.1		        <span style="color: #666666; font-style: italic;"># dns server 1</span>
<span style="color: #007800;">DNS2</span>=10.1.1.2                   <span style="color: #666666; font-style: italic;"># dns server 2</span>
<span style="color: #007800;">MANAGEMENTHOST</span>=x.x.x.x          <span style="color: #666666; font-style: italic;"># Management host</span>
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#---------------- variables --------------------------#</span>
<span style="color: #666666; font-style: italic;"># Bridge 0 (WAN)</span>
<span style="color: #007800;">BR0IP</span>=<span style="color: #ff0000;">&quot;10.1.1.2&quot;</span>            <span style="color: #666666; font-style: italic;"># ip of the LAN interface</span>
<span style="color: #007800;">BR0MASK</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span>       <span style="color: #666666; font-style: italic;"># subnetmask of the LAN</span>
<span style="color: #007800;">BR0IF1</span>=<span style="color: #ff0000;">&quot;eth0&quot;</span>                   <span style="color: #666666; font-style: italic;"># The physical LAN interface</span>
<span style="color: #007800;">BR0IF2</span>=<span style="color: #ff0000;">&quot;dummy0&quot;</span>                 <span style="color: #666666; font-style: italic;"># This should be the dummy</span>
<span style="color: #007800;">BR0GW</span>=<span style="color: #ff0000;">&quot;1&quot;</span>                       <span style="color: #666666; font-style: italic;"># 0 for no 1 for yes to enable the gateway</span>
<span style="color: #007800;">BR0GWIP</span>=<span style="color: #ff0000;">&quot;10.1.1.1&quot;</span>          <span style="color: #666666; font-style: italic;"># the ip of the gateway if BRI1GW=1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Bridge 1 (LAN)</span>
<span style="color: #007800;">BR1IP</span>=<span style="color: #ff0000;">&quot;192.168.10.2&quot;</span>          <span style="color: #666666; font-style: italic;"># ip of the LAN interface</span>
<span style="color: #007800;">BR1MASK</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span>         <span style="color: #666666; font-style: italic;"># subnetmask of the LAN</span>
<span style="color: #007800;">BR1IF1</span>=<span style="color: #ff0000;">&quot;eth1&quot;</span>                   <span style="color: #666666; font-style: italic;"># The physical LAN interface</span>
<span style="color: #007800;">BR1IF2</span>=<span style="color: #ff0000;">&quot;dummy1&quot;</span>                 <span style="color: #666666; font-style: italic;"># This should be the dummy</span>
<span style="color: #007800;">BR1GW</span>=<span style="color: #ff0000;">&quot;0&quot;</span>                       <span style="color: #666666; font-style: italic;"># 0 for no 1 for yes to enable the gateway</span>
<span style="color: #007800;">BR1GWIP</span>=<span style="color: #ff0000;">&quot;0.0.0.0&quot;</span>               <span style="color: #666666; font-style: italic;"># the ip of the gateway if BRI1GW=1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># A few paths</span>
<span style="color: #007800;">IPTABLES</span>=<span style="color: #ff0000;">&quot;/sbin/iptables&quot;</span>       <span style="color: #666666; font-style: italic;"># path to iptables</span>
<span style="color: #007800;">MODPROBE</span>=<span style="color: #ff0000;">&quot;/sbin/modprobe&quot;</span>       <span style="color: #666666; font-style: italic;"># path to modprobe</span>
<span style="color: #007800;">BRCTL</span>=<span style="color: #ff0000;">&quot;/usr/sbin/brctl&quot;</span>         <span style="color: #666666; font-style: italic;"># path to brctl</span>
<span style="color: #007800;">IFCONFIG</span>=<span style="color: #ff0000;">&quot;/sbin/ifconfig&quot;</span>       <span style="color: #666666; font-style: italic;"># path to ifconfig</span>
<span style="color: #007800;">ROUTE</span>=<span style="color: #ff0000;">&quot;/sbin/route&quot;</span>             <span style="color: #666666; font-style: italic;"># path to route</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Check how we are started</span>
<span style="color: #007800;">CMD</span>=$<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$CMD</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;start&quot;</span>; <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#--------------- And now the fun stuff ---------------#</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$CMD</span> = <span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#---------------- Create br0 -------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># load the module if needed</span>
 <span style="color: #007800;">MDCHK1</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`lsmod | grep -i dummy0 | awk {' print $1 '}`</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MDCHK1</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;dummy0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #007800;">$MODPROBE</span> dummy <span style="color: #660033;">-o</span> dummy0; <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create the bridge if needed</span>
 <span style="color: #007800;">BRCHK1</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`brctl show | grep br0 | awk {' print $1 '}`</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BRCHK1</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;br0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">$BRCTL</span> addbr br0
  <span style="color: #007800;">$BRCTL</span> addif br0 <span style="color: #007800;">$BR0IF1</span>
  <span style="color: #007800;">$BRCTL</span> addif br0 <span style="color: #007800;">$BR0IF2</span>
  <span style="color: #007800;">$BRCTL</span> stp br0 off
  <span style="color: #007800;">$IFCONFIG</span> <span style="color: #007800;">$BR0IF1</span> 0.0.0.0
  <span style="color: #007800;">$IFCONFIG</span> <span style="color: #007800;">$BR0IF2</span> 0.0.0.0
  <span style="color: #007800;">$IFCONFIG</span> br0 <span style="color: #007800;">$BR0IP</span> netmask <span style="color: #007800;">$BR0MASK</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BR0GW</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #007800;">$ROUTE</span> add default gw <span style="color: #007800;">$BR0GWIP</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#---------------- Create br1 -------------------------#</span>
<span style="color: #666666; font-style: italic;"># load the module if needed</span>
 <span style="color: #007800;">MDCHK1</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`lsmod | grep -i dummy1 | awk {' print $1 '}`</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MDCHK1</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;dummy1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #007800;">$MODPROBE</span> dummy <span style="color: #660033;">-o</span> dummy1; <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create the bridge if needed</span>
 <span style="color: #007800;">BRCHK1</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`brctl show | grep br1 | awk {' print $1 '}`</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BRCHK1</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;br1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">$BRCTL</span> addbr br1
  <span style="color: #007800;">$BRCTL</span> addif br1 <span style="color: #007800;">$BR1IF1</span>
  <span style="color: #007800;">$BRCTL</span> addif br1 <span style="color: #007800;">$BR1IF2</span>
  <span style="color: #007800;">$BRCTL</span> stp br1 off
  <span style="color: #007800;">$IFCONFIG</span> <span style="color: #007800;">$BR1IF1</span> 0.0.0.0
  <span style="color: #007800;">$IFCONFIG</span> <span style="color: #007800;">$BR1IF2</span> 0.0.0.0
  <span style="color: #007800;">$IFCONFIG</span> br1 <span style="color: #007800;">$BR1IP</span> netmask <span style="color: #007800;">$BR1MASK</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BR1GW</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #007800;">$ROUTE</span> add default gw <span style="color: #007800;">$BR1GWIP</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#--------------- Firewall default --------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Default policy: ACCEPT</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> FORWARD ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> INPUT ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> OUTPUT ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># Flush</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-F</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span> FORWARD
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span> INPUT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span> OUTPUT
&nbsp;
<span style="color: #666666; font-style: italic;"># Default policy: ACCEPT</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> FORWARD ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> INPUT ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> OUTPUT ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-------------- We put br0 in Aforward ---------------#</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Create Aforward</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> Aforward
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-i</span> br0 <span style="color: #660033;">-j</span> Aforward
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-o</span> br0 <span style="color: #660033;">-j</span> Aforward
&nbsp;
<span style="color: #666666; font-style: italic;"># Drop all crap on Aforward</span>
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> SYN,FIN SYN,FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> SYN,RST SYN,RST <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> FIN,RST FIN,RST <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,FIN FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,PSH PSH <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,URG URG <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">##### Firewall rules for br0 from here! ####</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##### Firewall rules for br0 until here! ####</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># drop the rest on Aforward</span>
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Aforward <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-------------- We put br1 in Bforward ---------------#</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Create Bforward</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> Bforward
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-i</span> br1 <span style="color: #660033;">-j</span> Bforward
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-o</span> br1 <span style="color: #660033;">-j</span> Bforward
&nbsp;
<span style="color: #666666; font-style: italic;"># Drop all crap on Bforward</span>
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> SYN,FIN SYN,FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> SYN,RST SYN,RST <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> FIN,RST FIN,RST <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,FIN FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,PSH PSH <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--tcp-flags</span> ACK,URG URG <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">##### Firewall rules for br1 from here! ####</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##### Firewall rules for br1 until here! ####</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># drop the rest on Bforward</span>
    <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> Bforward <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#--------------- Drop on FORWARD ---------------------#</span>
&nbsp;
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;[DROP-FORWARD] &quot;</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-------- Local Firewall Rules to this host ----------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## INPUT ##</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># VMWARE Console management hosts</span>
&nbsp;
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-s</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">902</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--sport</span> <span style="color: #000000;">902</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-s</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">8222</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--sport</span> <span style="color: #000000;">8222</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-s</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">8333</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$MANAGEMENTHOST</span> <span style="color: #660033;">--sport</span> <span style="color: #000000;">8333</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># ssh in from everyone and all interfaces</span>
&nbsp;
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">22</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;">## OUTPUT ##</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># port 80 to browse a bit for updates and stuff (you should limit this)</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">80</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># DNS lookups</span>
&nbsp;
 <span style="color: #007800;">DNSSERVERS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DNS1</span> <span style="color: #007800;">$DNS2</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">for</span> dnsip <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$DNSSERVERS</span>
  <span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--sport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT  <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-s</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">--sport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-d</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT  <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-s</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT  <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-s</span> <span style="color: #007800;">$dnsip</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
   <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$dnsip</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
  <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># deny rest</span>
&nbsp;
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;[DROP-INPUT] &quot;</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> DROP
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;[DROP-OUTPUT] &quot;</span>
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-j</span> DROP
 <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-j</span> DROP
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#---------------- End the if cmd=start ---------------#</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------------- Set default policy to DROP ------------#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> FORWARD DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> INPUT DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> OUTPUT DROP
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------#</span>
<span style="color: #666666; font-style: italic;">#eof</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.troublenow.org/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bond network interfaces in linux</title>
		<link>http://www.troublenow.org/archives/18</link>
		<comments>http://www.troublenow.org/archives/18#comments</comments>
		<pubDate>Mon, 03 Dec 2007 09:13:46 +0000</pubDate>
		<dc:creator>Arno Haverlach</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.troublenow.org/?p=18</guid>
		<description><![CDATA[Short intro:
Bonding (or &#8216;teaming&#8217;) network interfaces is a way to bind 2 interfaces as one. This way you can configure a more redundant network connection. A normal bonded setup should of course be connected to a redundant switch (lan port1 to switch 1, lan port 2 to switch 2). It is also possible to do [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Short intro:</strong></p>
<p>Bonding (or &#8216;teaming&#8217;) network interfaces is a way to bind 2 interfaces as one. This way you can configure a more redundant network connection. A normal bonded setup should of course be connected to a redundant switch (lan port1 to switch 1, lan port 2 to switch 2). It is also possible to do load balancing, but in this case traffic is low but availability should be high so i&#8217;m going for redundancy.</p>
<p>This setup is for a IBM Xserver running ubuntu 6.06.1 LTS server, this is a server with two Broadcom NetXtreme BCM5703X Gigabit Ethernet network interfaces which uses the &#8216;t3&#8242; module.</p>
<p>Before proceeding check what interfaces you have and what module you are using for your network interfaces.</p>
<p>To get started with &#8216;bonding&#8217; first you will need to look at your situation and check in what &#8216;mode&#8217; you want to configure the interface, while I normally use &#8216;mode: 2&#8242; this could maybe not work in your configuration so <a href="http://www.google.com/search?hl=en&amp;q=linux+bond+interfaces+modes&amp;btnG=Google+Search" title="Google" target="_blank">Google</a> for a few pages that explain the differences (this is a referance base remember..)</p>
<p><strong>The Configuration:</strong></p>
<p>First edit /etc/modprobe.d/aliases and at the end of the file add (be sure to change the module, mode and miimon if necessary) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> bond0 bonding
<span style="color: #7a0874; font-weight: bold;">alias</span> eth0 t3
<span style="color: #7a0874; font-weight: bold;">alias</span> eth1 t3
options bonding <span style="color: #007800;">mode</span>=<span style="color: #000000;">2</span> <span style="color: #007800;">miimon</span>=<span style="color: #000000;">100</span></pre></td></tr></table></div>

<p>Then edit /etc/modprobe.d/arch/i386 (and again be sure to change the module and miimon setting if necessary):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> bond0 bonding
options bonding <span style="color: #007800;">mode</span>=<span style="color: #000000;">2</span> <span style="color: #007800;">miimon</span>=<span style="color: #000000;">100</span> <span style="color: #007800;">downdelay</span>=<span style="color: #000000;">200</span> <span style="color: #007800;">updelay</span>=<span style="color: #000000;">200</span></pre></td></tr></table></div>

<p>First we need to check what mac interface we are going to use so use &#8216;ifconfig&#8217; to get the mac for the primary adapter in your server (this is the one I normally use).</p>

<div class="wp-terminal">trouble@sun:$ /sbin/ifconfig eth0<br/>eth0      Link encap:Ethernet  HWaddr YOUR MAC<br/>.....snap....<br/></div>

<p>Now edit /etc/network/interfaces, disable all the settings for the current interface (except lo of course) and add the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">auto bond0
iface bond0 inet static
   address 192.168.0.100
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255
   gateway 192.168.0.1
   hwaddress ether YOUR MAC
   post-up ifenslave bond0 eth0 eth1</pre></td></tr></table></div>

<p>Now reboot and you should be ready to go.</p>
<p><strong>Testing the config:</strong></p>
<p>Test it out by starting a ping to a other host in your network and unplug one cable at a time (no unplugging both interfaces won&#8217;t work..)</p>
<p>Also you can check the status with:</p>

<div class="wp-terminal">trouble@sun:$ cat /proc/net/bonding/bond0<br/>Ethernet Channel Bonding Driver: v3.0.0 (November 8, 2005)<br/><br/>Bonding Mode: load balancing (xor)<br/>Transmit Hash Policy: layer2 (0)<br/>MII Status: up<br/>MII Polling Interval (ms): 100<br/>Up Delay (ms): 200<br/>Down Delay (ms): 200<br/><br/>Slave Interface: eth0<br/>MII Status: up<br/>Link Failure Count: 0<br/>Permanent HW addr: MAC<br/><br/>Slave Interface: eth1<br/>MII Status: up<br/>Link Failure Count: 0<br/>Permanent HW addr: MAC<br/></div>

]]></content:encoded>
			<wfw:commentRss>http://www.troublenow.org/archives/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux VNC server</title>
		<link>http://www.troublenow.org/archives/5</link>
		<comments>http://www.troublenow.org/archives/5#comments</comments>
		<pubDate>Fri, 23 Feb 2007 19:47:47 +0000</pubDate>
		<dc:creator>Arno Haverlach</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.troublenow.org/?p=5</guid>
		<description><![CDATA[* Note that this is for debian based distro&#8217;s.
If you want to connect to your desktop or server that is running X you can install a vnc server to do so..
We will use gdm and xinetd to get it working so that if you boot up the computer it should all work at once.
To install [...]]]></description>
			<content:encoded><![CDATA[<p><strong>* Note that this is for debian based distro&#8217;s.</strong></p>
<p>If you want to connect to your desktop or server that is running X you can install a vnc server to do so..<br />
We will use gdm and xinetd to get it working so that if you boot up the computer it should all work at once.<br />
To install a vnc server you need atleast the following packages installed:</p>

<div class="wp-terminal">trouble@sun:$ apt-get install vnc4server gdm xinetd<br/></div>

<p>Then you will need to add a new service to the services list in /etc/services</p>

<div class="wp-terminal">trouble@sun:$ vi /etc/services<br/><br/>--here add at the end of the file:<br/><br/>vncserver    5900/tcp   # vnc server<br/></div>

<p>Then you need to change the gdm.conf file</p>

<div class="wp-terminal">trouble@sun:$ vi /etc/X11/gdm/gdm.conf<br/><br/>-- Here find the line [xdmcp] and change the option Enable=false to:<br/><br/>Enable=true<br/></div>

<p>Then add a file in /etc/xinetd.d/ called vncserver</p>

<div class="wp-terminal">trouble@sun:$ vi /etc/xinetd.d/vncserver<br/><br/>here add:<br/><br/>service vncserver<br/>{<br/>disable		=	no<br/>socket-type	=	stream<br/>protocol	=	tcp<br/>group           =       tty<br/>wait		=	no<br/>user		=	nobody<br/>server		=	/usr/bin/Xvnc<br/>server_args	=	-inetd -query localhost -geometry 1024x768 -depth 16 -once -fp unix/:7100 -securitytypes=none<br/>}<br/></div>

<p>Restart xinetd and you should be done..</p>

<div class="wp-terminal">trouble@sun:$ /etc/init.d/xinetd restart<br/></div>

<p>Try to connect to the box using a vnc viewer to :0</p>
]]></content:encoded>
			<wfw:commentRss>http://www.troublenow.org/archives/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
