Networking
Linux, like it's UNIX parents, was designed to be networked.
Static IP vs. DHCP
RHEL uses /etc/sysconfig/network-scripts/ifcfg-<foo>
for the interface configuration. <foo> will be eth0, eth1, bond0, wlan0 (for wireless). A file for eth0 running DHCP looks like
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller DEVICE=eth0 BOOTPROTO=dhcp DHCPCLASS= HWADDR=00:24:1D:80:2E:52 ONBOOT=yes
The full list of configurable parameters from RedHat's networking site is
BONDING_OPTS=<parameters>
BOOTPROTO=<protocol>
BROADCAST=<address>
DEVICE=<name>
DHCP_HOSTNAME
DNS{1,2}=<address>
ETHTOOL_OPTS=<options>
GATEWAY=<address>
HWADDR=<MAC-address>
IPADDR=<address>
MACADDR=<MAC-address>
MASTER=<bond-interface>
NETMASK=<mask>
NETWORK=<address>
ONBOOT=<answer>
PEERDNS=<answer>
SLAVE=<bond-interface>
SRCADDR=<address>
USERCTL=<answer>
NOTE The DEVICE= line must match the device name in the ifcfg-<device> filename. |
It is also possible to have virtual interfaces (VIP). Simply create an ifcfg-eth0:1 file with the device named eth0:1. It can have separate IP space from the physical device. The parameters that refer to hardware should be excluded from the ifcfg- file for VIPs as it makes no sense.
DNS
DNS is configured using the /etc/resolv.conf
file. Note the misspelling (missing "e" on the end). For system using DHCP, DNS is usually handled automatically by the dhclient process as seen here:
; generated by /sbin/dhclient-script search http://jimkinney.us nameserver 130.207.197.75 nameserver 130.207.197.73 nameserver 130.207.244.251
The first line begins with a ";" which is a valid comment as is "#". The search
line defines the default domain to append to a bare host name. The rest is simply the nameservers to use in order of preference.
NOTE The file |
NOTE If |
Firewalling with iptables
iptables is a very potent firewall process. It uses configuration files found in /etc/sysconfig/
and includes both an IPv4 and IPv6 configuration. The iptables-config
and ip6tables-config
are high-level configuration files controlling the general operation of iptables. The iptables
and ip6tables
files contain the actual rules used for the process when it is started by init. The rules files are only rw for the root user for security reasons. The iptables howto on the CentOS wiki is an excellent starter for iptables fundamentals. The RHEL 5.5 Firewall pages and the RHEL 5.5 iptables pages are essential reading for a solid background.
Commands for network control and information
The network system(s) will typically start at boot time from the init scripts./etc/init.d/network
controls the start and stop of the networking while/etc/init.d/NetworkManager
is used (in RHEL5) to make the best connection the default one for use. As is expected for init scripts, they typically require being run as root:/etc/init.d/<script> start|stop|restart|status
. Another way isservice <init script> start|stop|restart|status
Occasionally only a single network interface needs to be stopped or started.ifconfig <interface name> up|down
Networking exercise
|
Networking tools and testing
ping
ping is a first line check to see if a system is network-alive.ping -c 1 <host>
will send a single icmp request