Unix Network Programming Episode 8

Test Networks and Hosts

The figure shows The various networks and hosts used in the examples throughout the text. For each host, we show the OS and the type of hardware (since some of the operating systems run on more than one type of hardware). The name within each box is the hostname that appears in the text.

The topology is interesting for the sake of our examples, but the machines are largely spread out across the Internet and the physical topology becomes less interesting in practice. Instead, virtual private networks (VPNs) or secure shell (SSH) connections provide connectivity between these machines regardless of where they live physically.

The notation “/24” indicates the number of consecutive bits starting from the leftmost bit of the address used to identify the network and subnet. Section A.4(See 10.4) will talk about the /n notation used today to designate subnet boundaries.

The real name of the Sun OS is SunOS 5.x and not Solaris 2.x, but everyone refers to it as Solaris, the name given to the sum of the OS and other software bundled with the base OS.

Discovering Network Topology

We show the network topology in Figure 1.16 for the hosts used for the examples throughout this text, but you may need to know your own network topology to run the examples and exercises on your own network. Although there are no current Unix standards with regard to network configuration and administration, two basic commands are provided by most Unix systems and can be used to discover some details of a network: netstat and ifconfig.

netstat -i provides information on the interfaces. We also specify the -n flag to print numeric addresses, instead of trying to find names for the networks. This shows us the interfaces and their names.

luxuan@ubuntu:~$ netstat -ni
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33     1500    10243      0      0 0          2416      0      0      0 BMRU
ens38     1500       20      0      0 0           348      0      0      0 BMRU
lo       65536      354      0      0 0           354      0      0      0 LRU

The loopback interface is called lo and the Ethernet is called eth0. The next example shows a host with IPv6 support.

netstat -r shows the routing table, which is another way to determine the interfaces. We normally specify the -n flag to print numeric addresses. This also shows the IP address of the default router.

luxuan@ubuntu:~$ netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.243.2   0.0.0.0         UG        0 0          0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 ens38
192.168.102.0   0.0.0.0         255.255.255.0   U         0 0          0 ens38
192.168.243.0   0.0.0.0         255.255.255.0   U         0 0          0 ens33

你可能感兴趣的:(Linux,Unix,Network,Programming)