You are on page 1of 21

Configuring TCP/IP

Objectives
After completing this unit, students should be able to:
Configure TCP/IP Test the TCP/IP configuration

TCP/IP Configuration
Most distributions include TCP/IP configuration in install process Manual (re)configuration possible By hand By using the configuration tool of your distribution Red Hat: redhat-config-network SuSE: yast2 Configuration steps: Configure hostname Configure adapters Assign IP addresses Define routing information Configure name resolution

Configure Hostname
Done with the hostname command # hostname tux To configure hostname permanently, configure the startup file appropriate for your distribution Red Hat: /etc/sysconfig/network SuSE: /etc/HOSTNAME

Configure Adapters
Most adapters will be autodetected while booting the system - no further configuration necessary Some complications Multiple adapters Some adapters are not probed correctly To configure adapters manually, change lilo.conf or grub.conf (if support compiled into kernel) /etc/modules.conf (if support compiled as modules)
# cat /etc/lilo.conf . image=/boot/bzImage append="eth0=0x300,2,3c509" . # cat /boot/grub/grub.conf . title Red Hat Linux (2.4.18-3) kernel /vmlinuz-2.4.18-3 ro root=/dev/hda7 eth0=0x300,2,3c509 . # cat /etc/modules.conf alias eth0 3c509 options eth0 io=0x300 irq=2

Assign IP Addresses
Done with ifconfig
# ifconfig eth0 129.33.151.7 netmask 255.255.255.0 up

ifconfig without options shows the current configuration Make permanent by adding to the configuration files Red Hat: /etc/sysconfig/networking/devices/ifcfg-<device> SuSE: /etc/sysconfig/network/ifcfg-<device> To activate/deactivate an interface manually, using the ifcfg-<device> information, use ifup and ifdown
# ifup eth0 # ifdown eth0

Configuring Wireless Adapters


Wireless (IEEE 802.11) adapters are configured like ethernet adapters with a few extra parameters: Link speed (use "auto") SSID (Service Set IDentifier) WEP encryption keys and settings Done with iwconfig command:
# iwconfig eth1 rate auto essid "IBMEDUC" enc "1234567890"

Configuration generally stored alongside IP configuration in ifcfg-<device> files Can use redhat-config-network or yast to configure wireless parameters Other useful commands: iwlist: List information from wireless network iwspy: Display signal quality and strength

IP Aliases
Used to assign a second IP address to an adapter Useful when: Using multiple logical networks on one physical network Transitioning from one IP range to another Creating High-Availability clusters Testing To configure an alias on eth0, configure eth0:0, eth0:1, ... as if it were a normal interface
# ifconfig eth0:0 ... # vi ifcfg-eth0:0 ... # ifup eth0:0 ...

Configuring the Default Route


The Default Route is the "way out" of your local network Should be added to the routing table: # route add default 129.33.151.1 route without options gives all current routes Make permanent by adding to the configuration files Red Hat: /etc/sysconfig/network or /etc/sysconfig/networking/devices/ifcfg-<device> (*) SuSE: /etc/sysconfig/network/routes or /etc/sysconfig/network/ifcfg-<device> (*)

(*) Configuring a per-device default route is only useful on e.g. laptops, where not all devices are used simultaneously

Configuring Name Resolution


Hostnames easier to remember than IP addresses Almost every IP address will have an associated hostname To use hostnames, either: Edit local /etc/hosts file and add all hostnames to be used Set up name resolution through DNS in /etc/resolv.conf

/etc/hosts
# The format of the file is: # <IP Address> <Hostname> <Aliases> 127.0.0.1 129.33.151.7 129.33.151.1 129.33.151.201 129.33.151.202 # comments

loopback localhost sys7 sys1 router sys201 dns1 sys202 dns2

/etc/resolv.conf
search my_domain.com nameserver 129.33.151.201 nameserver 129.33.151.202

Testing Your Configuration


Verify local interfaces Verify routing Verify ARP table Verify connectivity Verify hostname resolution Verify open ports

Verify Local Interfaces


# ifconfig eth0 Link encap:Ethernet HWaddr: 00:50:56:81:00:01 inet addr:129.33.151.7 Bcast:129.33.151.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:49 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 interrupt:9 Base address:0x1000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:22 errors:0 dropped:0 overruns:0 frame:0 TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0

Verify Routing
# route Kernel IP routing table Destination Gateway 129.33.151.0 * default 129.33.151.1

Genmask 255.255.255.0 0.0.0.0

Flags U UG

Metric 0 0

Ref 0 0

Use 0 0

Iface eth0 eth0

Verify ARP Table


# arp Address 129.33.151.1

HWtype ether

HWaddress 00:A0:24:8A:85:BA

Flags Mask C

Iface eth0

Verify Connectivity
# ping 129.33.151.1 PING 129.33.151.1 (129.33.151.1) from 129.33.151.7 : 56(84) bytes of data. 64 bytes from 129.151.33.1: icmp_seq=0 ttl=255 time=5.0 ms 64 bytes from 129.151.33.1: icmp_seq=1 ttl=255 time=0.7 ms 64 bytes from 129.151.33.1: icmp_seq=2 ttl=255 time=0.7 ms 64 bytes from 129.151.33.1: icmp_seq=3 ttl=255 time=0.7 ms ^C --- 129.151.33.1 ping statistics --4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.7/1.7/5.0 ms

Verify Hostname Resolution


# host sys7 sys7.my_domain.com has address 129.33.151.7 # host 129.33.151.7 7.151.33.129.IN-ADDR.ARPA domain name pointer sys7.my_domain.com

Verify Open Ports


# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address tcp 0 0 *:www *:* tcp 0 0 *:smtp *:* tcp 0 0 *:printer *:* tcp 0 0 *:auth *:* tcp 0 0 *:finger *:* tcp 0 0 *:exec *:* tcp 0 0 *:login *:* tcp 0 0 *:shell *:* tcp 0 0 *:telnet *:* tcp 0 0 *:ftp *:* udp 0 0 *:ntalk *:* udp 0 0 *:talk *:* raw 0 0 *:icmp *:* raw 0 0 *:tcp *:* State LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN

7 7

Checkpoint
1. What is a good first command to use to test whether two hosts can talk to each other on a network? 2. What command can you use to test for proper name resolution, both name to address and address to name? 3. What command will display what is in your arp cache? 4. What command will show the network status including input and output packets transmitted on a network interface?

Unit Summary
To configure TCP/IP the following steps should be taken Configure adapters Set a hostname Configure IP addresses Define basic routing Configure name resolution Usually these steps are part of the installation process To test your configuration, various commands are useful: ifconfig route netstat arp ping

You might also like