Chapter 1 Advancer Linux Netword Administration Networking Configuration of lectures LPI 202 give you the knowledge: Linux Networking, Configuration Files, IP Netword Administration, Support Files,... Invite you to consult. Hope content useful document serves the academic needs and research.
Chapter 01 Advanced Linux Network Administration Networking Configuration SaigonCTT All rights reserved Objectives • Networking configuration – Should be able to configure a network device to be able to connect to a local network and a widearea network. – To be able to communicate between various subnets within a single network • Networking utilities LPI Linux Linux Networking • Drivers – An Ethernet driver is typically compiled into the kernel, but may be loaded as a kernel module at boot time • Interfaces – The Ethernet card interface is typically named "eth0". The loopback interface is typically named "lo" – /sbin/ifconfig a will show all interfaces – /sbin/ifconfig eth0 will show just the primary Ethernet card interface LPI Linux Configuration Files • All of these are in /etc • /etc/sysconfig/network Define whether to activate networking on boot and define the hostname of the machine • /etc/sysconfig/networkscripts/ifcfglo Configures the loopback interface (to 127.0.0.1) this interface allows you to use TCP/IP software without being connected to a LAN. • /etc/sysconfig/networkscripts/ifcfgeth0 Configures the primary Ethernet interface LPI Linux IP Network Configurations • Two choices: – Static IP address – Dynamic IP address • (a) Static IP address useful for servers – Example: Mike's notebook configured as a server • • /etc/sysconfig/network – NETWORKING=yes – HOSTNAME=gojira.l17.citncaat /etc/sysconfig/networkscripts/ifcfgeth0 – DEVICE=eth0 – ONBOOT=yes – IPADDR=192.168.93.254 – NETMASK=255.255.255.0 – GATEWAY=192.168.93.1 LPI Linux IP Network Configurations • (b) Dynamic IP address using DHCP – Example: Mike 's notebook configured as a mobile workstation using DHCP. • /etc/sysconfig/network – NETWORKING=yes – HOSTNAME=gojira • /etc/sysconfig/networkscripts/ifcfgeth0 – DEVICE=eth0 – BOOTPROTO=dhcp – ONBOOT=yes LPI Linux Support Files • /etc/hosts Lists static IP addresses and hostnames. – Example: • # Do not remove the following line, or various programs # that require network functionality will fail • 127.0.0.1 localhost.localdomain localhost • 192.168.90.157 gojira • /etc/resolv.conf Lists files, domains, and DNS servers to search to convert hostnames to IP addresses. – Example: • ; generated by /sbin/dhclientscript • search cogeco.ca • nameserver 192.168.0.1 LPI Linux Shell Script To Control Networking • /etc/init.d/network • Started by init when the system starts. You may also run it as "root" with any one of these following options: – /etc/init.d/network start – /etc/init.d/network stop – /etc/init.d/network restart – /etc/init.d/network reload – /etc/init.d/network status LPI Linux Common Utilities: ping • ping – The ping command allows the user to test whether or not a network connection is active, the speed of that connection, and how a network behaves given specific data loads • ping IPaddress Example: ping 203.162.44.34 • When the ping command is finished (or you manually stop it with CTRLC): – a minimum time – Average time – maximum time – percentage of packets that may have been lost is calculated LPI Linux Common Utilities: ifconfig • ifconfig also: ifcfg, ifup, ifdown, ethtool – The ifconfig command is a tool used to display and configure network interfaces. • Examples – ifconfig eth0 192.168.20.21 netmask 255.255.255.0 – ifconfig eth0 up – ifconfig eth0 down – ifconfig a 10 LPI Linux Common Utilities: hostname • hostname also: domainname, dnsdomainname – The hostname command tells you what the hostname of your machine is set to. – The hostname is determined from a number of sources, such as the /etc/sysconfig/network or /etc/hosts files • Example [root@proserv root]# hostname proserv [root@proserv root]# hostname webserv [root@proserv root]# hostname webserv [root@proserv root]# domainname vnuitp.edu.vn [root@proserv root]# domainname vnuitp.edu.vn 11 LPI Linux Common Utilities: nslookup • nslookup,host,dig – These commands query the DNS database to determine information about network hosts • Example $nslookup www.yahoo.com $nslookup >set type=any >vnn.vn $host www.vnn.vn $dig 12 LPI Linux Common Utilities: traceroute • traceroute also: tracepath – This program prints the route along which an IP packet travels from the local host to reach the destination host – Example: root@sleipnir root]# traceroute www.ibm.com 1 dvalin (192.168.168.252) 0.739 ms 0.364 ms 0.265 ms 2 midgard.lesbell.com.au (203.35.202.158) 1.890 ms 1.315 ms 1.292 ms 3 Loopback1.ken10.Sydney.telstra.net (165.228.2.1) 17.909 ms 19.071 ms 19.581 ms 4 10GigabitEthernet150.kencore4.Sydney.telstra.net (203.50.20.1) 31.446 ms 208.883 ms 171.406 ms 5 10GigabitEthernet30.padcore4.Sydney.telstra.net (203.50.6.86) 20.327 ms 20.912 ms 18.271 ms 6 GigabitEthernet22.sydcore01.Sydney.net.reach.com (203.50.13.38) 20.309 ms 20.360 ms 19.721 ms 7 i122.wilcore01.net.reach.com (202.84.144.25) 169.611 ms 170.647 ms 168.839 ms 8 202.84.251.166 (202.84.251.166) 191.602 ms 188.565 ms 177.935 ms 9 so10.core2.LosAngeles1.Level3.net (64.152.193.65) 201.521 ms 200.113 ms 202.050 ms 10 so410.bbr2.LosAngeles1.Level3.net (4.68.113.173) 201.732 ms 201.403 ms 201.674 ms 11 so300.mp1.Denver1.Level3.net (64.159.1.113) 228.770 ms 227.226 ms 229.076 ms 12 so60.hsa1.Denver1.Level3.net (4.68.112.154) 228.021 ms 228.383 ms 237.262 ms 13 unknown.Level3.net (209.245.20.10) 226.879 ms 228.772 ms 230.193 ms 13 LPI Linux Common Utilities: route • The routing tables are configured, checked and changed with the /sbin/route tool. • Add a static route: – /sbin/route add net 10.0.0.0 gw 192.168.1.108 dev eth1 • Add a default gateway: – /sbin/route add default gw 192.168.1.1 eth0 • Listing the kernel routing table: – /sbin/route n 14 LPI Linux Arp, arpwatch • arp also: arping – The arp command by itself is used to view the information currently in the ARP table (Address Resolution Protocol). This table maps the IP address of machines on your network segment with their MAC address • Example • [root@proserv root]# arp a bash: child setpgid (893 to 893): No such process ? (10.11.2.219) at 4C:00:10:38:AB:C6 [ether] on eth0 ? (10.11.1.7) at 00:10:B5:CC:9D:75 [ether] on eth1 ? (10.11.2.104) at 4C:00:10:60:2F:BB [ether] on eth0 ? (10.11.1.1) at 00:07:85:A3:32:A1 [ether] on eth1 ? (10.11.2.79) at 4C:00:10:71:AC:8B [ether] on eth0 ? (10.11.1.8) at 00:0F:EA:6A:2A:C2 [ether] on eth1 ? (10.11.1.23) at 00:0C:6E:45:57:45 [ether] on eth1 15 LPI Linux netstat • netstat – The netstat command displays details about the network: • • routing tables and other interface statistics. Active Internet Connections • Example [root@proserv root]# netstat an|more Active Internet connections (servers and established) Proto RecvQ SendQ Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 10.11.1.2:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN tcp 0 0 10.11.1.2:445 10.11.2.197:1055 ESTABLISHED tcp 0 192 10.11.1.2:22 10.11.2.83:49334 ESTABLISHED 16 LPI Linux Summary • Networking configuration – to configure a network device to be able to connect to a local network and a widearea network. – To be able to communicate between various subnets within a single network – Test connection with other hosts 17 LPI Linux ... ? (10 .11 .2. 219 ) at 4C:00 :10 :38:AB:C6 [ether] on eth0 ? (10 .11 .1. 7) at 00 :10 :B5:CC:9D:75 [ether] on eth1 ? (10 .11 .2 .10 4) at 4C:00 :10 :60:2F:BB [ether] on eth0 ? (10 .11 .1. 1) at 00:07:85:A3:32:A1 [ether] on eth1... tcp 0 0 10 .11 .1. 2:445 10 .11 .2 .19 7 :10 55 ESTABLISHED tcp 0 19 2 10 .11 .1. 2:22 10 .11 .2.83:49334 ESTABLISHED 16 LPI Linux Summary • Networking configuration. .. ? (10 .11 .1. 1) at 00:07:85:A3:32:A1 [ether] on eth1 ? (10 .11 .2.79) at 4C:00 :10 : 71: AC:8B [ether] on eth0 ? (10 .11 .1. 8) at 00:0F:EA:6A:2A:C2 [ether] on eth1 ? (10 .11 .1. 23) at 00:0C:6E:45:57:45 [ether] on eth1 15 LPI Linux netstat