You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

(ipconfig for windows/ ifconfig for linux og mac)

 

TDAT2004 Datakommunikasjon med nettverksprogrammering

Kategori:  Verktøy og hjelpeprogram

Oppgave 55: ipconfig/ifconfig

Karol Debik 

 

1. Innledning


Ipconfig/ifconfig (internet protocol configuration) er et verktøy som brukes for å vise nettverksgrensesnittet. Den viser aktuell TCP/IP konfigurasjon, samt visse DHCP og DNS innstillinger. Verktøyet hjelper å finne feil i: IP-addresse, subnet mask og default gateway.

Ipconfig kommandoen brukes i Windows systemer, mens ifconfig kommandoen brukes i UNIX-kloner og MAC systemer. For å ta i bruk ipconfig/ifconfig funksjonalitet må denne kommandoen skrives i kommandovinduet.


2. Ønsket funksjonalitet  


Ipconfig/ifconfig lister ut aktuelle innstillinger for IP-addresse, subnet mask og default for alle aktive fysiske og virtuelle adaptere.

Kommandoen med opsjoner kan brukes til endre systemets nåværende funksjonalitet, f.eks. oppdatere, registrere og slette innstillinger knyttet til DHCP og DNS.

3. Virkemåte


Syntaksen

ipconfig [/all] [/renew [Adapter]] [/release [Adapter]] [/flushdns] [/displaydns] [/registerdns] [/showclassid [Adapter] [/setclassid [Adapter [ClassID]]


ifconfig [-v] [-a] [-s] [interface]

ifconfig [-v] interface [aftype] options | address ...

 

Parametere/opsjoner:


ipconfig [paremeter]

Forklaring

ifconfig [parameter]

Forklaring

/all

Displays the full TCP/IP configuration for all adapters. Without this parameter, ipconfig displays only the IP address, subnet mask, and default gateway values for each adapter. Adapters can represent physical interfaces, such as installed network adapters, or logical interfaces, such as dial-up connections.

-a

Display information for all network interfaces, even if they are down.

/renew [ Adapter ]

Renews DHCP configuration for all adapters (if an adapter is not specified) or for a specific adapter if the Adapter parameter is included. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically. To specify an adapter name, type the adapter name that appears when you use ipconfig without parameters.

-s

Display a short list in a format identical to the command "netstat -i".

/release [ Adapter ]

Sends a DHCPRELEASE message to the DHCP server to release the current DHCP configuration and discard the IP address configuration for either all adapters (if an adapter is not specified) or for a specific adapter if the Adapter parameter is included. This parameter disables TCP/IP for adapters configured to obtain an IP address automatically. To specify an adapter name, type the adapter name that appears when you use ipconfig without parameters.

-v

Verbose mode; display additional information for certain error conditions.

/flushdns

Flushes and resets the contents of the DNS client resolver cache. During DNS troubleshooting, you can use this procedure to discard negative cache entries from the cache, as well as any other entries that have been added dynamically.

interface

The name of the interface. This is usually a driver name followed by a unit number, for example "eth0" for the first Ethernet interface. If your kernel supports alias interfaces, you can specify them with eth0:0 for the first alias of eth0. You can use them to assign a second address. To delete an alias interface use ifconfig eth0:0 down. Note: for every scope (i.e. same net with address/netmask combination) all aliases are deleted, if you delete the first (primary).

/displaydns

Displays the contents of the DNS client resolver cache, which includes both entries preloaded from the local Hosts file and any recently obtained resource records for name queries resolved by the computer. The DNS Client service uses this information to resolve frequently queried names quickly, before querying its configured DNS servers.

up

This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the interface.

/registerdns

Initiates manual dynamic registration for the DNS names and IP addresses that are configured at a computer. You can use this parameter to troubleshoot a failed DNS name registration or resolve a dynamic update problem between a client and the DNS server without rebooting the client computer. The DNS settings in the advanced properties of the TCP/IP protocol determine which names are registered in DNS.

down

This flag causes the driver for this interface to be shut down.

/showclassid [Adapter]  

Displays the DHCP class ID for a specified adapter. To see the DHCP class ID for all adapters, use the asterisk (*) wildcard character in place of Adapter. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically.

[-]arp

Enable (or disable, if the "-" prefix is specified) the use of the ARP protocol on this interface.

/setclassid   Adapter [ ClassID ]

Configures the DHCP class ID for a specified adapter. To set the DHCP class ID for all adapters, use the asterisk (*) wildcard character in place of Adapter. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically. If a DHCP class ID is not specified, the current class ID is removed.

[-]promisc

Enable (or disable, if the "-" prefix is specified) the promiscuous mode of the interface. If promiscuous mode is enabled, all packets on the network will be received by the interface.

/?

Displays help at the command prompt.

[-]allmulti

Enable or disable all-multicast mode. If multicast mode is enabled, all multicast packets on the network will be received by the interface.

 

 

metric N

This parameter sets the interface metric, which is used by the interface to make routing decisions. N must be an integer between 0 and 4294967295. If you're not sure what a network metric is, or whether you should change it, you can safely leave this setting alone.

 

 

mtu N

This parameter sets the Maximum Transfer Unit (MTU) of an interface. This setting is used to limit the maximum packet size transferred by the interface. If you're not sure about it, you can safely leave this setting alone.

 

 

dstaddr address

Set the remote IP address for a point-to-point link (such as PPP). This keyword is now obsolete; use the pointopoint keyword instead.

 

 

netmask address

Set the IP network mask for this interface. This value defaults to the usual class A, B or C network mask (as derived from the interface IP address), but it can be set to any value.

 

 

add address/prefixlen

Add an IPv6 address to an interface.

 

 

del address/prefixlen

Remove an IPv6 address from an interface.

 

 

tunnel aa.bb.cc.dd

Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.

 

 

irq address

Set the interrupt line used by this device. Not all devices can dynamically change their IRQ setting.

 

 

io_addr address

Set the start address in I/O space for this device.

 

 

mem_start address

Set the start address for shared memory used by this device. Only a few devices need this.

 

 

media type

Set the physical port or medium type to be used by the device. Not all devices can change this setting, and those that can vary in what values they support. Typical values for type are 10base2 (thin Ethernet), 10baseT (twisted-pair 10Mbps Ethernet), AUI (external transceiver) and so on. The special medium type of auto can be used to tell the driver to auto-sense the media. Again, not all drivers can do this.

 

 

[-]broadcast [address]

If the address argument is given, this will set the protocol broadcast address for this interface. Otherwise, it will set (or clear, if the "-" prefix is used) the IFF_BROADCAST flag for the interface.

 

 

[-]pointopoint [address]

This keyword enables the point-to-point mode of an interface, meaning that it is a direct link between two machines with nobody else listening on it. If the address argument is also given, set the protocol address of the other side of the link, just like the obsolete dstaddr keyword does. Otherwise, set or clear the IFF_POINTOPOINT flag for the interface.

 

 

hw class address

Set the hardware address of this interface, if the device driver supports this operation. The keyword must be followed by the name of the hardware class and the printable ASCII equivalent of the hardware address. Hardware classes currently supported include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).

 

 

multicast

Set the multicast flag on the interface. This should not normally be needed as the drivers set the flag correctly themselves.

 

 

address

The IP address to be assigned to this interface.

 

 

txqueuelen length

Set the length of the transmit queue of the device. It is useful to set this to small values for slower devices with a high latency (such as a connection over a modem, or over ISDN) to prevent fast bulk transfers from disturbing interactive traffic like telnet too much.

 

Eksempler:

ipconfigviser kort konfigurasjon om alle aktive grensesnitt

ipconfig /allviser all data til alle grensesnitt

ipconfig /renewfornyer alle DHCP adresser

ipconfig /releasefrigir alle DHCP adresser

ipconfig /? eller ipconfig /viser hjelp menu

ipconfig /flushdnsrenser DNS buffor

ipconfig /displaydnsviser DNS→IP



Skjermbilde av ipconfig /all kommando (hentet fra nettet)

 

ifconfig – viser konfigurasjon om alle aktive grensesnitt

ifconfig -a – viser konfigurasjon om alle aktive og inaktive grensesnitt

ifconfig eth0 – viser nettverksinnstillinger i eth0 grensesnittet

ifconfig eth1 up – aktiverer eth1 grensesnittet

ifconfig wlan0 downdeaktiverer wlan0 grensesnittet

ifconfig wlan1 122.140.201.66 – konfigurerer wlan1 grensesnittet til å bruke statisk IP-adresse 122.140.201.66

ifconfig wlan0 netmask 255.255.255.0 – konfigurerer wlan0 grensesnittet til å bruke nettmask 255.255.255.0

ifconfig eth0 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255 – konfigurerer eth0 grensesnittet til å bruke statisk IP-adresse 192.168.1.102 ved å bruke netmask 255.255.255.0, og broadcast adress 192.168.1.255


Skjermbildet av endring ip adress ved hjelp av ifconfig interface netmask adress.

4. Referanser


  1. https://help.ubuntu.com/lts/serverguide/network-configuration.html#ip-addressing (hentet 31.03.2017)

  2. https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.cmds3/ifconfig.htm (hentet 31.03.2017)

  3. http://www.computerhope.com/unix/uifconfi.htm (hentet 31.03.2017)

  4. https://technet.microsoft.com/en-us/library/bb490921.aspx (hentet 31.03.2017)

  • No labels