Subscribe RSS

Tag-Archive for "kernel"

How to force source IP address on linux May 21

UPDATE: THIS INFORMATION IS INCORRECT AND CAN LEAD TO KERNEL PANICS

On linux servers where interfaces are multi homed on the same subnet there is a very common issue. You can not determine or set what IP address is used to source connections. This can make a security nightmare when trying to lock down services to a single IP that keeps changing. Do not fear, There is a way to force outgoing connections to use a specific ip address.

This little trick uses IPtables and is something known as source nat’ing. It does the exact opposite as regular nat or DNAT. So go grab some IPtables binaries if you dont already have them and we shall get started.

# iptables -t nat -A POSTROUTING -m state --state new -j SNAT --to-source 1.2.3.4

That is all that is required. All new connections ie connections originating from the box will be forced to use the IP address of 1.2.3.4

Category: Linux  | Tags: , , , , ,  | Leave a Comment
Linux Panic Button May 09

Have you ever been doing some administration and *poof* everything has frozen nothing works the only thing left to do is restart the system right?

wrong!

There is a lesser known panic button built in to the kernel that will gracefully restart everything by stopping daemons and dismounting drives.

To do this you must hold alt+SysReq (PrintScreen) and type “REISUB” (busier backwards) you may or may not get kernel messages printed to the screen if you dont after finishing typing the system  will gracefully restart.

This is made possible by a feature of the linux kernel that some perople refer to as the “magical sysreq commands”. More information on this can be found Here.

Category: Useful tidbits  | Tags: , ,  | Leave a Comment
Linux terminal tty resolution Mar 27

babe_wayhayWith a lot of linux distributions the default tty resolution will work with almost all old hardware. You may have noticed that this compatible (default) resolution is klunky and not particularly useful when trying to view large amounts of data. It is infact possible to change the resolution to anything as high as 1280×1024. This is a feature of the linux kernel that can be set at boot time. First look at the table below

Colour Depth 640×480 800×600 1024×768 1280×1024
8 (256) 769 771 773 775
15 (32k) 784 787 790 793
16 (65k) 785 788 791 794
24 (16M) 786 789 792 795

This table enables you to choose your tty resolution and colour depth and you are left with a number e.g. 1024×768 16bit = 791.

This number now needs to be put in to the line of your bootloader where the kernel is loaded. (/boot/grub/menu.lst) I have only ever used grub but im sure it will work with lilo and other boot loaders.

Look for the line like:
kernel       /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda1 ro quiet

and add vga=791 so the line looks like this:
kernel       /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda1 ro quiet vga=791

Now reboot the machine and the tty resolution will be what you set.

Category: Linux  | Tags: , , , ,  | Leave a Comment