1. Convert DHCP network configuration to static configuration
Your main network configuration file is /etc/network/interfaces
Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254
Open network configuration file
$ sudo vi /etc/network/interfacesOR$ sudo nano /etc/network/interfaces
Find and remove dhcp entry:
iface eth0 inet dhcp
Append new network settings:
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
Save and close the file. Restart the network:
$ sudo /etc/init.d/networking restart
Task: Define new DNS servers
Open /etc/resolv.conf file
$ sudo vi /etc/resolv.conf
You need to remove old DNS server assigned by DHCP server:
search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30
Save and close the file.
Task: Test DNS server
$ host cyberciti.biz
Network command line cheat sheet
You can also use commands to change settings. Please note that these settings are temporary and not the permanent. Use above method to make network changes permanent or GUI tool as described below.
Task: Display network interface information
$ ifconfig
Task: Take down network interface eth0 / take a network interface down
$ sudo ifconfig eth0 downOR $ sudo ifdown eth0
Task: Bring a network interface eth0 up
$ sudo ifconfig eth0 upOR$ sudo ifup eth0
Task: Change IP address and netmask from command line
Activate network interface eth0 with a new IP (192.168.1.50) / netmask:
$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up
Task: Display the routing table
$ /sbin/route OR$ /sbin/route -n
Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
localnet * 255.255.255.0 U 0 0 0 ra0
172.16.114.0 * 255.255.255.0 U 0 0 0 eth0
172.16.236.0 * 255.255.255.0 U 0 0 0 eth1
default 192.168.1.254 0.0.0.0 UG 0 0 0 ra0
Task: Add a new gateway
$ sudo route add default gw 172.16.236.0
Task: Display current active Internet connections (servers and established connection)
$ netstat -nat
Task: Display open ports
$ sudo netstat -tulpOR$ sudo netstat -tulpn
Task: Display network interfaces stats (RX/TX etc)
$ netstat -i
Task: Display output for active/established connections only
$ netstat -e
$ netstat -te
$ netstat -tue
Where,
- -t : TCP connections
- -u : UDP connections
- -e : Established
Task: Test network connectivity
Send ICMP ECHO_REQUEST to network hosts, routers, servers etc with ping command. This verifies connectivity exists between local host and remote network system:
$ ping router
$ ping 192.168.1.254
$ ping cyberciti.biz
See simple Linux system monitoring with ping command and scripts for more information.
Task: Use GUI (Graphical Configuration) network Tool
If you are new, use GUI configuration tool, type the following command at terminal:
$ network-admin &
Above command is Ubuntu's GUI for configuring network connections tool.
Final tip - Learn how find out more information about commands
A man page is your best friend when you wanted to learn more about particular command or syntax. For example, read detailed information about ifconfig and netstat command:
$ man ifconfig
$ man netstat
Just get a short help with all command options by appending --help option to each command:
$ netstat --help
Find out what command is used for particular task by searching the short descriptions and manual page names for the keyword:
$ man -k 'delete directory'
$ apropos -s 1 remove
Display short descriptions of a command:
$ whatis rm
$ whatis netstat
Linux offers an excellent collection of utilities, which can be use to finding the files and executables, remember you cannot memorize all the commands and files ![]()
2. Automatic IP Configuration with DHCP Server on Ubuntu
This article is a work in progress.
$ sudo apt-get install dhcp3-server
edit following file:
# /etc/default/dhcp3-server
INTERFACES="eth0"
then,
$ sudo nano -w /etc/dhcp*/dhcpd.conf # dhcpd.conf for Helia labs
# Copyright 2006 Tero Karvinen http://www.iki.fi/karvinen/ubuntu_dhcp.html
# License: GNU General Public License, version 2 or later
# ChangeLog:
# 2006-03-27 Initial version, testing in Helia labs
# Don't set "authoritative" until everything else is correct in dhcpd.conf
authoritative; # Warning: this overrides other DHCP servers
# Default options in Ubuntu:
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
# Subnet row defines server's network card. Also set in "/etc/default/dhcp3-server"
# 'ifconfig' shows subnet (ipaddress, zeroes as in mask) and netmask
subnet 172.28.0.0 netmask 255.255.0.0 {
host terotestaa {
# 'ping target_host', 'arp' shows MAC address
# only give DHCP information to this computer:
hardware ethernet 00:0D:56:73:F0:0D;
# Basic DHCP info (see 'ifconfig', 'route', 'cat /etc/resolv.conf')
fixed-address 172.28.1.7;
option subnet-mask 255.255.0.0;
option routers 172.28.1.254;
option domain-name-servers 172.28.1.67, 172.28.1.69;
# Non-essential DHCP options
option domain-name "tielab.helia.fi";
}
}
# 'sudo /etc/init.d/dhcp3-server force-reload'
# http://www.iki.fi/karvinen/ubuntu_dhcp.html
$ sudo /etc/init.d/dhcp3-server stop
Now that you have DHCP working, you could try Ubuntu PXE.
Ref. http://myy.helia.fi/~karte/ubuntu_dhcp.html
3. PXE Network Booting on Ubuntu Linux
How to use PXE network boot to install workstations automatically. This article is a work in progress. Copyright 2006-2008 Tero Karvinen
Make DHCP work.
Add PXE configuration to dhcpd.conf:
next-server 172.28.1.103;
filename "pxelinux.0";
Install TFTP server. Also install client for testing. Trivial file transfer protocol is not related to FTP.
$ sudo apt-get install tftpd-hpa tftp-hpaConfigure TFTP server. Notice nice path for TFTPd root (don’t use “/tftpsomething”). In RUN_DAEMON, “yes” must be small caps.
$ sudo nano /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /home/pxetero/"
Add a user for TFTP service:
$ sudo adduser pxetero
Allow your normal user to modify /home/pxetero/. Ues your own username and group instead of tkarvine.
$ whoami
tkarvine
$ sudo chown pxetero.tkarvine /home/pxetero/
$ sudo chmod g+rwx /home/pxetero
Now you can modify files in TFTPd root dir (/home/pxetero/) without using sudo.
Download netboot files to /home/pxetero. (mirror of netboot files):
$ cd /home/pxetero
$ wget -np -r http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/
$ mv archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/* .
$ rm -rf archive.ubuntu.com/
Kernel “linux” and initial RAM disk image “initrd.gz” must match the version of your distribution. Change version nickname (breezy, dapper, feisty, gutsy) in the url accordingly. For example, 7.04 Feisty’s kernel and initrd are http://archive.ubuntu.com/ubuntu/dists/feisty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz and http://archive.ubuntu.com/ubuntu/dists/feisty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux
Start TFTP server and test it
$ sudo /etc/init.d/tftpd-hpa start
$ cd
$ tftp localhost -c get pxelinux.0
$ ls pxeli*
pxelinux.0
Now that it works (pxelinux.0 was downloaded successfully), start DHCP server:
$ sudo /etc/init.d/dhcp3-server start
Boot your target workstation (the one whose MAC number is in dhcpd.conf). The installer should start automatically.
If that worked, it is time to enable kickstart:
$ nano /home/pxetero/pxelinux.cfg/default
Under “label linux”, in the end of “append” row, add your kickstart like
ks=http://www.example.com/ks.cfg
Change timeout to non-zero value
timeout 100
Now that you boot your workstation from network, kickstart should work and workstation should install automatically.
You can even automate waking up the computer from shutdown state. Enable “universe”, and install “wakeonlan” or “etherwake”.
Try booting the client computer (either manually choosing network boot or by magic packet). If the installer starts and asks for language, congratulations, your setup works!
What Next?
In Helia labs, boot with magic packet usually works once, and the it does not work for a long while. Probably related to switch settings.
It works, now what? - Collect IP numbers from switch - Make your own mirror of all ubuntu packages (use wget -r -X to download) - Test the whole package: magic packet, pxe, kickstart
Appendix: Modified dhcpd.conf for PXE
# Copyright 2006 Tero Karvinen http://www.iki.fi/karvinen
# License: GNU General Public License, version 2 or later
# ChangeLog:
# 2006-03-27 Initial version, testing in Helia labs
# Don't set "authoritative" until everything else is correct in dhcpd.conf
authoritative; # Warning: this overrides other DHCP servers
# Default options in Ubuntu:
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
# Subnet row defines server's network card. Also set in "/etc/default/dhcp3-server"
# 'ifconfig' shows subnet (ipaddress, zeroes as in mask)
subnet 172.28.0.0 netmask 255.255.0.0 {
host terotestaa {
# 'ping target_host', 'arp' shows MAC address
# only give DHCP information to this computer:
hardware ethernet 00:0D:F0:1C:22:33;
# Basic DHCP info (see 'ifconfig', 'route', 'cat /etc/resolv.conf')
fixed-address 172.28.1.7;
option subnet-mask 255.255.0.0;
option routers 172.28.1.254;
option domain-name-servers 172.28.1.67, 172.28.1.69;
# Non-essential DHCP options
option domain-name "tielab.helia.fi";
# TFPT server for PXE boot
server-name "172.28.1.103";
filename "pxelinux.0";
}
}
# 'sudo /etc/init.d/dhcp3-server force-reload'
# http://www.iki.fi/karvinen
Appendix: Modified pxelinux.cfg/default for Kickstart
display ubuntu-installer/i386/boot-screens/syslinux.txt
default linux
F1ubuntu-installer/i386/boot-screens/f1.txt
F2 ubuntu-installer/i386/boot-screens/f2.txt
F3 ubuntu-installer/i386/boot-screens/f3.txt
F4 ubuntu-installer/i386/boot-screens/f4.txt
F5 ubuntu-installer/i386/boot-screens/f5.txt
F6 ubuntu-installer/i386/boot-screens/f6.txt
F7 ubuntu-installer/i386/boot-screens/f7.txt
F8 ubuntu-installer/i386/boot-screens/f8.txt
F9 ubuntu-installer/i386/boot-screens/f9.txt
F0 ubuntu-installer/i386/boot-screens/f10.txt
label linux
kernel ubuntu-installer/i386/linux
append vga=normal initrd=ubuntu-installer/i386/initrd.gz ramdisk_size=16432 root=/dev/rd/0 rw -- ks=http://iki.fi/karvinen/notexists-ks.cfg
label expert
kernel ubuntu-installer/i386/linux
append DEBCONF_PRIORITY=low vga=normal initrd=ubuntu-installer/i386/initrd.gz ramdisk_size=16432 root=/dev/rd/0 rw --
label server
kernel ubuntu-installer/i386/linux
append base-config/package-selection= base-config/install-language-support=false vga=normal initrd=ubuntu-installer/i386/initrd.gz ramdisk_size=16432 root=/dev/rd/0 rw --
label server-expert
kernel ubuntu-installer/i386/linux
append base-config/package-selection= base-config/install-language-support=false DEBCONF_PRIORITY=low vga=normal initrd=ubuntu-installer/i386/initrd.gz
ramdisk_size=16432 root=/dev/rd/0 rw --
prompt 1
timeout 20
Ref. http://myy.helia.fi/~karte/ubuntu_pxe.html
download file :
http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/
*** Change version nickname (breezy, dapper, feisty, gutsy) in the url accordingly. For example, 8.04 Hardy’s kernel and initrd are
http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/
********************************************************************************************
PXE Server for install OS on network
https://help.ubuntu.com/community/PXEInstallServer
********************************************************************************************