Useful things to keep in mind when setting up a service:
- always take note of what you do
- make yourself always able to explain to another person what you did
- keep a copy of the configuration files before changing them, so that you can see what you changed
- be always able to move the service to another computer
- make sure that it works after reboot
Example use of vim
block selection:
ESC
: exits insert mode.^V
: starts block selection. Move the arrows to form a rectangle.c
: change. Type the new content for the line.ESC
: gets out of insert mode, and the change will happen in all the lines.
To change network configuration with config files, edit:
/etc/network/interfaces
To also setup DNS in /etc/network/interfaces
, use dns-search
and
dns-nameservers
(for this to work, you need to have the package
resolvconf
):
dns-search dream.edu.et
dns-nameservers 192.168.0.1 192.168.0.2
To make a router that connects to the internet on demand using a modem:
apt-get install diald
To see the path of network packets:
mtr 4.2.2.2
Basic NAT script:
OUT=eth2
IN=eth0
modprobe iptable_nat
iptables -t nat -A POSTROUTING -o $OUT -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
What happens at system startup:
- the BIOS loads and runs the boot loader
- the boot loader loads the kernel and the inintrd ramdisk and runs the kernel
- the kernel runs the script 'init' in the initrd ramdisk
- the script 'init' mounts the root directory
- the script 'init' runs the command /sbin/init in the new root directory
- 'init' starts the system with the configuration in /etc/inittab
To install a new startup script:
sudo ln -s /usr/local/sbin/firewall /etc/init.d
sudo update-rc.d firewall defaults 16 75
Normally you can just do:
sudo update-rc.d [servicename] defaults
To have a look at the start and stop order numbers, look at /etc/rc2.d
for
other start scripts and /etc/rc0.d
for other stop scripts
To test a proxy, low level way:
$ telnet proxy 8080
Trying 192.168.0.6...
Connected to proxy.dream.edu.et.
Escape character is '^]'.
GET http://www.google.com HTTP/1.0 [press enter twice]