Second TCPIP Network Configuration under UNIX Platform

xiaoxiao2021-03-06  63

Second TCP / IP Network Configuration under UNIX Platform

Li Shouliang SLLI@founder.com.cn

Last Version: 2003-2-18

Brief description

If you encounter the changes, the server borrowing, etc., often needs to change the IP or host name of the server. In this section, this section will provide temporary and permanent approach to reference. At the same time, some issues related to some and TCP / IP configurations are involved. This section is mainly Sun Solaris 5.8, and other UNIX systems are available for reference.

Welcome to forward, spread, welcome to Fang Zheng Group, welcome to supplement, welcome to correct.

table of Contents

1. How do I use the ifconfig command on UNIX to configure IP Address? # Immediately take effect, restart the failure

2, how to use Sys-Unconfig restore Sun Sorlaris configuration?

3. How do I configure IP Address by modifying files on UNIX? # 久 方法 方法

4, how to modify the host name (hostname)?

5. How to make it take effect immediately after modifying the gateway?

6, how to use the command to implement single-NIC multi IP, and how to delete #. Immediately take effect, restart the failure

7. How do I achieve multiple IPs permanently on Solaris? # 重 重 重 机 有 后

8. Some common usage of ifconfig.

9. How do I install a network card driver on Solaris x86?

10. How do I install multiple network cards on Sun? For example, how to install 3 blocks on the Sun workstation?

11. How do I get my machine MAC address in the program? # This section is extracted, for reference only

12. How to determine the NIC Capability / Speed ​​on the Solaris / FreeBSD / Linux platform?

13. How to directly join other UNIX machine names (without IP)?

14, DNS server settings See a separate document

15, to be supplement

content

============================================================================================================================================================================================================= =======

1. How do I use the ifconfig command on UNIX to configure IP Address? (Effective immediately, restart failure)

grammar:

Ifconfig

Netmask Broadcast

Example:

#ifconfig hme0 162.105.183.12 Netmask 255.255.255.0 Broadcast 162.105.183.255

#ifconfig -a

LO0: Flags = 1000849 MTU 8232 INDEX 1

INET 127.0.0.1 Netmask FF000000

HME0: Flags = 1000843 MTU 1500 INDEX 2

inet 162.105.183.12 netmask ffffff00 broadcast 162.105.183.255ether 0: 3: ba: 1f: f2: 9d

============================================================================================================================================================================================================= =======

2, how to use Sys-Unconfig restore Sun Sorlaris configuration?

Under the root identity, run # sys-unconfig, restore all Sun configuration. The system will restart and reconfigure each parameter. Be careful with this command, sys-unconfig is doing the following:

o SAVES CURRENT / ETC / INET / HOSTS File Information In /etc/inet/hosts.saved.

Oiff The Current / etc / vfstab File Contains NFS Mount Entries, SAVES The / etc / vfstab file to /etc/vfstab.orig.

o Retores the default / etc / inet / hosts file.

o Removes the default hostname in /etc/hostname.interface files for all interfaces configured when this command is run. To determine which interfaces are configured, run the command 'ifconfig- a'. The /etc/hostname.interface files corresponding To all of the interfaces listed in the resulting out- put, with the exception of the loopback interface (LO0), WILL BE Removed.

O Removes The Default DomainName IN / ETC / DefaultDomain.

o Retores the timezone to PST8PDT IN / ETC / TIMEZONE.

o Disables The Network Information Service (NIS) AND NetWork Information Service Plus (NIS ) IF Either Nisor NIS WAS Configured. Network Information Service Plus (NIS ) IF Either NIS OR NIS WAS Configured.

O Removes The Entries for this Host In / etc / net / * / hosts.

o Removes the file / etc / inet / netmasks.

O Removes The File / etc / defaultRouter.

o Removes the password set for root in / etc / shadow.

o Removes the file /etc/.rootkey.o Executes all system configuration applications. These applications are defined by prior executions of a sysidconfig -a application. (See sysidconfig (1M)). When sys-unconfig is run, all system configuration applications Are Passed One Argument, -u.

o Removes the file /etc/resolv.conf/

.

Related documents:

/ etc / default / init / init

Process Control InIstization

/ etc / defaultdomain

/ etc / defaultrouter

/etc/hostname.interface

/ etc / inet / hosts

Host Name Database

/ ETC / INET / NETMASKS

NetWork Mask Database

/ etc / net / * / hosts

/ etc / nodename

/ etc / nodename

/etc/.rootkey

Super-user's secret key

/ etc / shadow

Shadow Password File

/ ETC / VFSTAB

Virtual File System Table

/ VAR / NIS / NIS_COLD_START

/ VAR / YP / BINDING / * / YPSERVERS

Reference Related Documents: #man sys-unconfig

============================================================================================================================================================================================================= =======

3. How do I configure IP Address by modifying files on UNIX? # 久 方法 方法

If you encounter a website change, server borrowing, etc., you need to change the server's IP or host name. The temporary method will restart the machine will invalid. If you need a permanent change, use the sys-unconfig command to avoid some cannon feelings, reload The system is not worthless, and you can see the method implementation below.

Solaris reform address method:

Modify the following file. Note: The HOSTS, NETWORKS under / etc, is actually a symbolic connection to files under / etc / inet.

1). / Etc / hosts # Add (Modify) Machine Name and Address

E.g:

127.0.0.1 Localhost

162.105.183.12 SLLISUN LOGHOST

2). / Etc / networks

E.g:

Loopback 127

Arpanet 10 Arpa # Historical3). / etc / netmasks # Modify subnet mask

E.g:

162.105.183.0 255.255.255.0

4). / Etc / net / * / hosts # * is Ticlts, Ticots, Ticotsord three directories, change the HOSTS in three directories

E.g:

#ident "@ (#) Hosts 1.2 92/07/14 SMI" / * SVR4.0 1.2 * /

# RRPC HOSTS

SLLISUN SLLISUN

5). / Etc / nodename #NodeName is the host name, this file is easy to change

E.g:

SLLISUN

6). / Etc / hostname. #Iinterface is the NIC name

E.g:

File /etc/hostname.hme0

SLLISUN

7). / Etc / defaultrouter # Add gateway address

Generally, this file does not exist when installing. If there is no existence, it is necessary to manually create.

E.g:

162.105.183.1

8. /etc/resolv.conf #dns client settings, reform domain name

E.g:

Domain rd.corp.founder.com.cn

Nameserver 162.105.170.59

If you have available Domain and Nameserver, set up DNS clients, you can not only directly ping the host name of Neighbors, but also through Sun to send and receive mail.

There is a dedicated tool NetConfig configuration on Linux, which is no longer described here.

============================================================================================================================================================================================================= ==========

4, how to modify the host name (hostname)?

1). Need to modify the following file

/ etc / hosts

/ etc / hostname.

/ etc / nodename

/ etc / net / * / hosts (3 files, man -s 7d ticy "

2) If you run in VXVM, you should

# vxdctl hostid

# vxdctl init

============================================================================================================================================================================================================= ======= 5, how to make it immediately after modifying the gateway?

There is a gateway configuration file defaultrouter in the / etc / directory. Generally after installing the system, this file does not exist. If manually created or modified, the machine does not restart the machine to take effect immediately, and the following command can be used.

E.g:

1). Create files / etc / defaultrouter

#touch / etc / defaultrouter

#echo 162.105.183.1> / etc / defaultrouter

2). # Route -f add default `Cat / etc / defaultrouter` 1

============================================================================================================================================================================================================= =======

6. How to use a command mode to implement a single network card multiple IP, and how to delete? # Immediately take effect, restart the failure

Use the ifconfig command to add IP:

Syntax: ifconfig Addif Netmask Broadcast

Example:

1) Check the network card type

# ifconfig -a

LO0: Flags = 1000849 MTU 8232 INDEX 1

INET 127.0.0.1 Netmask FF000000

HME0: Flags = 1000843 MTU 1500 INDEX 2

INET 162.105.183.12 Netmask ffffffff00 Broadcast 162.105.183.255

Ether 0: 3: BA: 1F: F2: 9D

2) Add IP address 162.105.183.249 to NIC HME0

#ifconfig hme0 addif 162.105.183.249

Created New Logical Interface HME0: 1

# ifconfig -a

LO0: Flags = 1000849 MTU 8232 INDEX 1

INET 127.0.0.1 Netmask FF000000

HME0: Flags = 1000843 MTU 1500 INDEX 2

inet 162.105.183.12 netmask ffffff00 broadcast 162.105.183.255ether 0: 3: ba: 1f: f2: 9d

HME0: 1: Flags = 1000842 MTU 1500 INDEX 2

INET 162.105.183.249 Netmask fff0000 Broadcast 162.105.255.255

Similarly, add other mask and broadcast addresses with the following command:

# i1055.255.255.0 Broadcast 162.255.183.255

Created New Logical Interface HME0: 2

Use the ifconfig command to delete multiple IPs:

Grammar: ifconfig Removeif

Example:

# ifconfig hme0 removeif 162.105.183.249

============================================================================================================================================================================================================= =======

7. How do I achieve multiple IPs permanently on Solaris?

The following is a Lance Ethernet (LE0) device as an example.

Successful case example:

1) Edit / etc / hosts file

162.105.183.12 MyHost

162.105.183.249 myhost2

162.105.183.250 myhost3

2) Create a /etc/hostname.le0:n file, pay attention to hostname.le0: 0 is hostname.le0

/etc/hostname.le0 (content is MyHost)

/etc/hostname.le0:1 (content is myhost2)

/etc/hostname.le0:2 (content is MyHost3)

Note that this file is a line, the host name.

3) If you want to take effect immediately

# i10: 1 UP

# ifconfig le0: 1 162.105.183.249

# i10: 2 Up

# ffconfig le0: 2 162.105.183.250

Or restart the server, automatically add new IP

4) make it fail

# ifconfig le0: 1 Down

# ifconfig le0: 2 Down

5) IFCONFIG -A verification

Note: The following is an extract for reference.

Excerpt one:

Q: How do I give multiple IP addresses to a Ethernet card under Solaris 8?

A:

IFConfig Le0 Plumb

Ifconfig le0 Ether 0: 1: 2: 3: 4: 5

IFConfig Le0: 1 PlumbB

IFCONFIG LE0: 1 ... UP

IFConfig Le0: 2 Plumb

IFCONFIG LE0: 2 ... UP

Modify the IP address, subnet mask, etc. set in /etc/init.d directory.

D: SCZ

There are three files to pay attention, / etc / rcs.d / s30Rootusr.sh (/etc/init.d/rootusr), / etc / rc2.d / s69inet (/etc/init.d/inetinit) and / etc / rc2 .d / s72inetsvc (/etc/init.d/inetsvc). Extract 2:

Q: How to bind multiple IP addresses on a physical network card

A: Sun Microsystems 1997-10-27

The so-called virtual network interface refers to a plurality of different IP addresses of a physical interface. Solaris allows a physical network interface to correspond to multiple logical interfaces. In other words, even if there is only one network card, multiple IP addresses can be configured. See ifconfig (1M) man page. For Solaris 2.x, 256 different IP addresses can be bound to a single network card.

Sun OS 4.x (Solaris 1.x) is not supported.

/ usr / sbin / ndd -get / dev / ip ip_addrs_per_if

For Solaris 2.6, more than 256 (0-255) IP addresses can be configured by NDD.

/ usr / sbin / ndd -set / dev / ip ip_addrs_per_if 1-8192

Add this command to the /etc/rc2.d/s69inet launch script.

1) Edit the / etc / hosts file (or Nis Host Map) to increase the entry for each virtual interface. Don't forget

Change NIS, NIS , DNS database.

2) Create /etc/hostname. files for each interface, such as /etc/hostname.le0:1,

Hostname.le0: 2, hostname.le0: 3 ... Le0: 255. The file content is a single line IP address or the main

Machine name. For example, create the following file

/etc/hostname.le0:1 (Do not use LE0: 0, that is Le0)

/etc/hostname.le0:2

Up to 1024 virtual interfaces under Solaris 2.5.1. Each file content is your own virtual interface IP address or host name.

3) If the subnet is used, it should be added to / etc / netmasks.

Network_address Netmask

157.145.0.0 255.255.255.0

4) Restart the system

5) IFCONFIG -A verification

Some third-party applications may have problems at this time. For security reasons, you can

NDD -SET / DEV / IP IP_FORWARDING 0

NDD -SET / DEV / IP IP_STRICT_DST_MULTIHOMING 1

See RFC1112 - << Host Extensions for IP Multicasting >>.

If you don't expect the virtual interface, you will consider manual "route delete". You can add a startup script /etc/rc2.d/s99VIF to complete these tasks. For Solaris 2.6, NDD -SET / DEV / IP IP_ENABLE_GROUP_IFS 0 (2.6 down default is 1, 7 down default is 0), add this command to the /etc/rc2.d/s69inet startup script .

============================================================================================================================================================================================================= ========== 8, some common usage of ifconfig

Other usage See # ifconfig

Common Syntax: ifconfig Netmask Broadcast | -A | UP | DOWN

1) Ifconfig Command Use the -a option to see all interfaces existing in the machine, when using the specific interface instead of the -A option in the ifconfig command: All parameters of the interface:

Example:

# ifconfig -a

LO0: Flags = 1000849 MTU 8232 INDEX 1

INET 127.0.0.1 Netmask FF000000

HME0: Flags = 1000843 MTU 1500 INDEX 2

INET 162.105.183.12 Netmask ffffffff00 Broadcast 162.105.183.255

Ether 0: 3: BA: 1F: F2: 9D

# ifconfig hme0

HME0: Flags = 1000843 MTU 1500 INDEX 2

INET 162.105.183.12 Netmask ffffffff00 Broadcast 162.105.183.255

Ether 0: 3: BA: 1F: F2: 9D

2) Ifconfig Netmask Broadcast Changing Network Configuration

Example:

#ifconfig hme0 162.105.183.12 Netmask 255.255.255.0 Broadcast 162.105.183.255

3) Remove the HME0 interface and return to the online

Example:

#ifconfig hme0 down

#ifconfig hme0 up

4) Establish the broadcast address from the assigned network mask and IP address to the HME0 network interface:

Example:

#ifconfig hme0 Broadcast

5) Increase the IP address that deletes an HME0 interface

Example:

#ifconfig hme0 addif 162.105.183.249 -------- increase

#ifconfig hme0 removeif 162.105.183.249 -------- Delete

6) Change to DHCP mode

Grammatical # i i ifig | auto-dhcp | DHCP

Other usage See # ifconfig

Note: Any change will take effect immediately with the ifconfig command.

WARNING: If you are connected to the host through a Telnet network to perform remote configuration management, you may lose the connection once you reconfigure the interface.

============================================================================================================================================================================================================= ========== 9, how to install a network card driver on Solaris x86

No need to modify the "PCN.conf" file. If it is just "touch / reconfigure", Solaris X86 detected the NIC, but "ifconfig -a" only has a loopback interface, so I tried as follows:

# Drvconfig

# devlinks

# Touch / Reconfigure

Everything OK after restart

============================================================================================================================================================================================================= ==========

10. How do I install multiple network cards on Sun? For example, how to install 3 blocks on a Sun workstation.

Please follow the steps below:

1) Add a network card on the Sun workstation

2) Start the system with Boot -R

3) Observe the startup information, confirm that each network card is identified, such as this information

PCI-Device: Network @ 1, 1, HME # 0

SUNW, HME0 IS / PCI @ 1F, 4000 / NetWork @ 1, 1

In practice, if each network card is identified, there is HME0, HME1, and HME2, of course 1 and 2 may not be this name.

4) Create hostname.hme0, hostname.hme1, and hostname.hme2 in / etc directory. The IP address is specified in each file, and the editing / etc / hosts file increases the corresponding entry.

5) Restart the machine

============================================================================================================================================================================================================= ==========

11, how to get this machine MAC address in the program # 录

Q: How to get this machine MAC address in C code, I use Strace to track ifconfig

IOCTL (4, SiocGiFhwaddr, 0xBfffb80) = 0

IOCTL (4, Siocgifaddr, 0xBffFFB80) = 0

IOCTL (4, Siocgifbrdaddr, 0xBfffb80) = 0iocTl (4, SiocgifNetmask, 0xBfffb80) = 0

D: UNIX Programmer

Use gethostname () / gethostByname () depends on the domain name resolution system of this unit, such as / etc / hosts file, / etc / nsswitch.conf file, / etc / resolv.conf file. This acquisition is unreliable. If native IP is specified in the / etc / hosts file, depending on whether the DNS is configured with PTR resource records. Reliable approach should be Strace ifconfig, Truss ifconfig, actually getting the native IP according to the implementation of IFConfig.

A: David Peter

Strace is a tool under Linux. Since the HP-UX 10.20 IOCTL does not support Siocgifhwaddr, you may need a DLPI interface or NetStat IOCTL for / dev / lan0. In order to use NetStat IOCTL, you need to restart, and HP does not agree to continue using NetStat IOCTL, HP-UX 11.00 is no longer supported.

According to an old tool, Digital Unix supports the Siocrphysaddr. As for IRIX on SGI, I think there is a raw socket, such as:

s = socket (pf_raw, sock_raw, rawproto_sno)

D: SCZ 2001-11-20 11:46

Under SPARC / Solaris can only see the machine MAC address ifconfig -a, and ordinary users cannot do this, but they can try to find in DMESG output, because DMESG is likely to be destroyed, this method is not reliable . "ARP " can see that the machine MAC address is actually the IOCTL (S, Siocgarp, & ArpReq) of the previous programming demonstration, and you can use the following command to get the machine MAC address

NDD / DEV / ARP ARP_CACHE_REPORT | GREP MyAddr

============================================================================================================================================================================================================= ==========

12. How to determine the NIC Capability / Speed ​​on the Solaris / FreeBSD / Linux platform?

1) On Sun Solaris:

# netstat -k hme0 | GREP IFSPEED

# n n g g / dev / hme link_mode

0 semi-duplex

1 full duplex

# NDD -GET / DEV / HME LINK_STATUS

0 LINK DOWN

1 link Up

# NDD -GET / DEV / HME LINK_SPEED

0 10MBPS

1 100Mbps

2) FreeBSD:

Use ifconfig commands you can see

STATUS: Active Network cable is connected to a hub on Status: no carrier missed network cable

3) On Linux:

There is a mii-Tool command in the Net-Tools package in a high version of the Linux system, which can be used to check this data instead of dissolving in the output of IFCONFIG.

============================================================================================================================================================================================================= ==========

13, how to directly join the UNIX machine name (no ip)?

From UNIX to UNIX, if you want to perform sessions via HostName, you need to configure the entry file / etc / hosts file.

Example: / etc / hosts

127.0.0.1 Localhost

162.105.183.12 SLLISUN LOGHOST

162.105.183.8 SunServer1

162.105.183.9 SunServer2

162.105.183.10 Newsun

162.105.183.13 zzssun

162.105.183.14 app250

162.105.183.15 EnpsVR

162.105.183.35 AIX

To add the other party IP and HostName to / etchosts, you can use HostName instead of IP directly accessing the other party server.

============================================================================================================================================================================================================= ==========

14, DNS server settings See a separate document

============================================================================================================================================================================================================= ==========

15, to be supplement

Li Shouliang SLLI@founder.com.cn

2003-2-18

转载请注明原文地址:https://www.9cbs.com/read-106529.html

New Post(0)