180 likes | 185 Views
Day 14. Introduction to Networking. Unix Networking. Unix is very frequently used as a server. Server is a machine which “serves” some function Web Server FTP Server Mail Server All of these are examples of network services. You would most often use them across a network. Routing.
E N D
Day 14 Introduction to Networking
Unix Networking • Unix is very frequently used as a server. • Server is a machine which “serves” some function • Web Server • FTP Server • Mail Server • All of these are examples of network services. • You would most often use them across a network.
Routing • In order for any services to work, Unix must be able to communicate with its network successfully. • Must have a valid static address • Must have the correct Netmask • Must have a default route set. • May need additional routes • Must have valid DNS servers configured.
IP addresses • To view or set the IP address of your unix system, you use • ipconfig • To set the IP address of the first ethernet card you would type: • ifconfig eth0 10.0.0.1 • To see the current settings of your network cards, you would just type: • ifconfig
Netmask • A netmask is necessary to tell your system which network it is in. • The netmask is set with the command • ifconfig • e.g. • ifconfig eth0 10.0.0.1 netmask 255.255.255.0 • You should find the appropriate netmask for your network out before configuring your unix machine.
Default Route • The default route is very important. Without it, your system will not be able to get to the internet successfully. • Usually the default route should point to either: • The router which you got from your ISP when you bought your service. • Your firewall/gateway device.
Seeing your routes • netstat –rn • This will show you all routes which are currently configured on your system. • Most of these are built from the default route.
Adding/removing a route • route add –net 192.168.0.0 netmask 255.255.0.0 gw 10.0.0.254 • route add –net default gw 10.0.0.253 • Removing Routes: • route delete –net default • route delete –net 192.168.0.0 netmask 255.255.0.0
Networking Utilities • There are some helpful tools built into Unix to help you trouble shoot Networking problems. • Ping • Traceroute • nslookup • dig • tcpdump
Configuring DNS resolver • Your system must know how to resolve DNS names into IP addresses. • It does this by looking up its list of resolvers, and querying the first one listed. • The DNS resolvers are stored in: • /etc/resolv.conf • This has nothing to do with your machine being a DNS server. That’s is totally separate.
Ping • Allows you to see if a remote machine is available on the internet. • An ICMP echo request is sent to the remote machine. • If that machine it up, it will reply with an ICMP echo reply. • Typically you would send a number of requests and see if you get all of the packets back. • This provides data about how reliable your connection is. • Ping also provides round trip time to show network latency problems
traceroute • If you believe your internet connection is down, how can you tell where the problem is? • traceroute sends packets to each router between you and the destination, requesting that each router reply. • Once a router doesn’t reply, you can tell that is where the communication brake is. • You probably want to use the –n option on traceroute most of the time.
nslookup • So you are trying to get to web sites, and they are all timing out. Why? • Perhaps your machine cannot lookup DNS information. • nslookup allows you to see if you can resolve DNS queries (lookup names in the phone book) • Very often your network connection is setup perfectly, however you can’t resolve DNS, to you it looks like the internet is down.
Options for nslookup • server • Specifies which server you wish to ask questions of. • Useful to verify that a particular server is available and serving the correct information. • type • Allows you to look up the different types of DNS records • A, PTR, NS, MX
dig • Another tool which does basically the same things as nslookup. However this one ships with BIND. • Gives you more verbose output • Some people find it more intuitive to use.
tcpdump • Standard packet sniffer, which allows you to see what traffic is passing by on your segment. • This is very useful for diagnosing network problems, where packets don’t seem to be getting to a destination, you can watch along the way. • This also poses a security risk, as any machine on a network can sniff the traffic on that network.
Seeing what services are running • The command • netstat –a • will show you a list of all ports which your computer is currently listening on. • In general you only want it to be listening on ports which you are trying to run a service on. • More about that later. • It will also show you a list of all currently connected clients.
inetd.conf • This file specifies which services your machine is listening for connections on. • As a connection comes in, Linux looks up in this file to see what daemon should handle the request. • This is how you can prevent your machine from serving some service.