Wednesday, September 2, 2009

Split Screen on vi terminal

Sometimes we need to open multiple files even though we are aware of diff and many other ways of file comparison . We can open two or more files in split windows for comparison.
we will open two files in same terminal window..
open first file normally as we do 
$ vi first.txt
for opening second file in same vi display type 
$ :new second.txt
to navigate in between the windows use
ctrl + w
j     (move to lower window)
or
ctrl + w
k   (move to upper window)

for expanding a split window to full big screen 
:only
you can also open a new file by just typing 
:new 

if file opened by :new is now named , you wont be able to save it with just 
:wq 
instead u have to give 
:wq nameForNewFile.txt
Keep giving comments .. :)

Friday, August 28, 2009

Sharing internet using iptables

I am explaining how two share internet from one connection to other, here i am using one connection on my ethernet port to share with the wireless add hoc network.

settings at ethernet port (eth0)
IP : 192.168.1.9
MASK : 255.255.255.0
Gateway : 192.168.1.1

my laptop is configured to get internet from modem connected through LAN port and IP address of Modem is 192.168.1.1

settings for my Wifi Adaptor(wan0)
IP : 192.168.0.1
MASK : 255.255.255.0
Gateway : 192.168.1.1

now after this i have created an add hoc network so the systems connecting to my WiFi add hoc network must have following configuration
IP : 192.168.0.[2-254]
MASK : 255.255.255.0
Gateway : 192.168.0.1
DNS  : 192.168.0.1

Now configuration part is done, next we need to setup sharing, first of all we will enable ip forwarding by issuing following command as root user
sysctl -w net.ipv4.ip_forward=1
To enable it in system startup, edit the file /etc/sysctl.conf and set
net.ipv4.ip_forward = 1
now for sharing do the following commands. this should again be done as root user
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save

I use open DNS for better resolution, you can also tryout same
208.67.222.222
208.67.220.220