Repair MBR from linux

Use install-mbr to overwrite the MBR:

install-mbr -i n -p D -t 0 /dev/sde
Repalce sde with proper device letter. The options are:

-i interrupt (n=none/do not display a MBR prompt)
-p partition (D=boot the partition which has bootable flag set)
-t timeout (0=do not wait before boot)

More on manpage: http://xgen.iit.edu/cgi-bin/man/man2html?install-mbr+8

Messing with iptables connection tracking

iptables -A FORWARD -m recent --name badguy --rcheck --seconds
60 -j DROP

 
iptables -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name
badguy --set -j DROP

Steve’s ipt_recent website (http://snowman.net/projects/ipt_recent/)
also has some examples of usage.

/proc/net/ipt_recent/* are the current lists of addresses and informa‐
tion about each entry of each list.

Each file in /proc/net/ipt_recent/ can be read from to see the current
list or written two using the following commands to modify the list:

echo +addr >/proc/net/ipt_recent/DEFAULT
to add addr to the DEFAULT list

echo -addr >/proc/net/ipt_recent/DEFAULT
to remove addr from the DEFAULT list

echo / >/proc/net/ipt_recent/DEFAULT
to flush the DEFAULT list (remove all entries).

Ubuntu – GRE Tunnel

Creating a tunnel on Ubuntu

Edit /etc/network/interface file and add this code

auto gre1
iface gre1 inet static
    address 
    netmask 
    pointopoint 
    pre-up iptunnel add gre1 mode gre local  remote  ttl 255
    up ifconfig gre1 multicast
    post-down iptunnel del gre1

You might also need to “modprobe ip_gre” in some cases before activating the tunnel.

Ubuntu – disable USB automount

Hate it when Ubuntu unnecessarily mounts USB drives when you are doing some R&D.

Here’s a quick way to disable it.

$ gconftool-2 --type bool --set /apps/nautilus/preferences/media_automount false

You can also use gconf-editor to set it to false. Once done, just set it to true again to make it auto-mount.

Ubuntu – reset root password

If you forgot your root password or to login to Ubuntu (for recovery) without the root password, follow these simple steps:

  • While the computer boots, press ‘Esc’ as soon as the Grub loads to go into the menu.
  • Press ‘e’ to edit the boot menu
  • Select the kernel line and again press ‘e’
  • remove the words ‘ro’, ‘quite’ and ‘splash’
  • put these words at the end – ‘rw init=/bin/bash’
  • press enter to accept
  • then press ‘b’ to boot into linux

Now you will get to the root shell in a while. Mount all partitions using ‘mount -a’ command (somtimes some partitions are not mounted). Then use ‘passwd’ command to set a new password. Or, you can perform maintenance task right there.