Sie sind auf Seite 1von 11

OpenSolaris Network Commands

OpenSolaris Network Commands

Page: 1 of 11

OpenSolaris Network Commands

Page: 2 of 11

Table of contents
OpenSolaris Network Commands............................................................................................................................1 1. Overview...............................................................................................................................................................4 1.1 dladm Command............................................................................................................................................4 1.2 Route command..............................................................................................................................................4 1.3 ifconfig Command..........................................................................................................................................4 1.4 netstat Command............................................................................................................................................4 2. Status ....................................................................................................................................................................6 2.1 General Information.......................................................................................................................................6 2.2 Interface Statistics..........................................................................................................................................6 2.2.1 Interfaces Graph.......................................................................................................................................6 3. Settings..................................................................................................................................................................7 3.1 Network..........................................................................................................................................................7 3.1.1 Network....................................................................................................................................................7 3.1.2 Configured Network Interface(NI)...........................................................................................................8

OpenSolaris Network Commands

Page: 3 of 11

1. Overview
On OpenSolaris the default behavior is to configure network interfaces automatically. If automatic configuration is disabled then immediate changes to network configuration are made with these commands: ifconfig route dladm netstat

1.1 dladm Command


Used on the data-link layer of the TCP/IP networking stack. The two most common forms of this command are the dladm show-dev command and the dladm show-link command to show existing links on the system. # dladm show-dev LINK STATE SPEED eri0 up 100Mb full DUPLEX

The dladm show-dev command displays the current network devices that are installed on your system, their current state, speed, and duplex mode, which can be either half or full. # dladm show-link ce0 type: legacy bge0 type: non-vlan bge1 type: non-vlan mtu:1500 mtu:1500 device:ce0 device:bge0

mtu: 1500 device: bge1

The dladm show-link command: Lists links that are congured on top of the devices in your system Shows the maximum packet size for transmission (MTU) and the type of device. Take the name of their corresponding device names

1.2 Route command


Route command manipulates the kernel routing tables. Routing is the process of forwarding a packet from one computer to another. Syntax: route [-fn] add | delete | get [net|host|default] [destination] [gateway]

1.3 ifconfig Command


Used to obtain information about interfaces on the IP layer of the TCP/IP stacks. Use ifconfig interface to obtain information about a specic interface, or use ifconfig -a to see information about all the interfaces.

1.4 netstat Command


Syntax: netstat options The following table lists selected options that might be most useful for monitoring the network Shows network status and protocol statistics Display the status of TCP, SCTP, and UDP endpoints in table format Display routing table and interface information

OpenSolaris Network Commands

Page: 4 of 11

Option -s -p protocol -i -a -f inet | inet6 -r -D -n

Displayed Information Statistics per protocol. All protocols are included in the command output, such as IP, IGMP, IPMP, RAWIP, SCTP, TCP, and UDP Statistics about the specied protocol. Status and other information about each network interface on the system. Status of sockets on the local system. Statistics about a family of addresses, either IPv4 addresses if you specify inet, or IPv6 addresses if you specify inet6. Routing-table information. Status of interfaces that are congured for DHCP. Used in combination with any of the previously listed options where applicable. Displays network addresses as numbers instead of symbols.

OpenSolaris Network Commands

Page: 5 of 11

2. Status
2.1 General Information 2.2 Interface Statistics
2.2.1 Interfaces Graph
2.2.1.1 List all the interfaces whether or not they are plumbed. #dladm show-link Ex: # dladm show-link LINK e1000g0 CLASS phys MTU STATE -OVER 1500 up

2.2.1.2 Show the state of interfaces #dladm show- phys interface Ex: #dladm show-phys e1000g0 LINK e1000g0 MEDIA Ethernet STATE up SPEED DUPLEX DEVICE 1000 full

OpenSolaris Network Commands

Page: 6 of 11

3. Settings
3.1 Network
3.1.1 Network
3.1.1.1 Configuring a route 3.1.1.1.1 To add a route Use p to make persistent rout change Ex: # route -p add net 172.16.17.0/24 10.10.17.81 add net 172.16.17.0/24: gateway 10.10.17.81 3.1.1.1.2 To show route # route -p show 3.1.1.1.3 To delete route Ex: # route -p delete net 172.16.17.0/24 10.10.17.81 delete net 172.16.17.0/24: gateway 10.10.17.81 delete persistent net 172.16.17.0/24: gateway 10.10.17.81 3.1.1.1.4 To see how the system would route a packet to a specific address Use route get, for ex: # route get www.google.com route to: cf-in-f103.google.com destination: default mask: default gateway: 10.10.17.81 interface: e1000g0 flags: <UP,GATEWAY,DONE,STATIC> recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu 0 0 0 0 0 0 expire

3.1.1.1.5 To change Default Gateway/Default Router in Sun Solaris This Default Gateway is maintained in the file /etc/defaultrouter To view the existing Kernel IP Routing table, using # netstat rn # netstat rn Routing Table: IPv4 Destination 192.168.1.0 224.0.0.0 default 127.0.0.1 Gateway 192.168.1.10 192.168.1.10 192.168.1.1 127.0.0.1 Flags Ref U U UG UH 1 1 1 5 Use Interface - 195 hme0 0 hme0 325 92 lo0

To remove the existing default gateway: # route delete default 172.1.1.1 To add the new Default Gateway using: # route add default 192.168.1.1 3.1.1.2 DNS Settings Open solaris includes both DNS Server and DNS client(resolver)
OpenSolaris Network Commands Page: 7 of 11

3.1.1.2.1 Conguring the DNS resolver Using the le /etc/resolv.conf When OpenSolaris automatically configures the network, DNS is usually set up by DHCP .The most basic resolv.conf contains a nameserver statement: nameserver 192.168.1.7. We can edit this file to add more DNS.

3.1.2 Configured Network Interface(NI)


3.1.2.1 Configure NI automatically with NWAM 3.1.2.1.1 NWAM Automatically configure physical NI Configure using DHCP Configure a single NI at a time Priority is wired interface first, if fails, then configure wireless interfaces Switch between wired and wireless by plugging/unplugging the Ethernet cable

3.1.2.1.2 Enable NWAM # svcadm disable network/physical:default # svcadm enable network/physical:nwam 3.1.2.1.3 Check status # svcs nwam 3.1.2.1.4 Restart NWAM # svcadm restart nwam 3.1.2.2 Configure NI manually Disable NWAM and enable manually mode # svcadm disable network/physical:nwam # svcadm enable network/physical:default 3.1.2.2.1 To list all the interfaces # dladm show-link Ex: # dladm show-link LINK CLASS MTU STATE OVER e1000g0 phys 1500 up e1000g1 phys 1500 up -3.1.2.2.2 To Rename a Network Interface # dladm rename-link e1000g0 eth0 Ex: # dladm show-link LINK e1000g0 CLASS phys MTU 1500 up STATE -OVER

# dladm rename-link e1000g0 eth0 # dladm show-link


OpenSolaris Network Commands Page: 8 of 11

LINK eth0 #

CLASS phys

MTU

STATE

OVER

1500 unknown --

3.1.2.2.3 To create an IP interface attached to a Link # ifconfig interface plumb Ex: # ifconfig e1000g0 plumb 3.1.2.2.4 To verify that the interface is properly plumbed with ifconfig: # ifconfig interface # ifconfig e1000g0 e1000g0: flags=201000842<BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2 inet 0.0.0.0 netmask 0 3.1.2.2.5 To configure a DHCP interface 1.1.1.1.1.1. Configure Temporarily DHCP interface will be clear if system reboot # ifconfig interface dhcp start Ex: # ifconfig e1000g0dhcp start To verify it completed successfully by checking the interfaces conguration with ifconfig. # ifconfig e1000g0 e1000g0: flags=201004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,CoS> index 2 inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255 1.1.1.1.1.2. Configure permanemently Create 2 files: /etc/hostname.interface and /etc/dhcp.interface Ex: The following command congures the e1000g0 interface persistently: # touch /etc/hostname.e1000g0 /etc/dhcp.e1000g0 The empty /etc/hostname.e1000g0 le causes: + The interface to be plumbed + DHCP to be started on the interface 3.1.2.2.6 To stop DHCP on an interface # ifconfig e1000g0 dhcp release Stop DHCP on this interface and inform DHCP ifconfig e1000g0 dhcp drop Stop DHCP but not inform DHCP server. DHCP must release it when expired. 3.1.2.2.7 To persistent de-congure an interface after stopping Remove both the hostname.interface and dhcp.interface les. Ex: # rm /etc/hostname.e1000g0 /etc/dhcp.e1000g0 3.1.2.2.8 To configure a static IP interface In this case, we dont use DHCP server 1.1.1.1.1.1. Temporarily
Page: 9 of 11

mtu

1500

OpenSolaris Network Commands

To congure an IP interface temporarily with a static address, use ifconfig: # ifconfig e1000g0 inet 192.168.1.20/24 To bring it up # ifconfig e1000g0 inet up 1.1.1.1.1.2. Persistently The persistent conguration for a statically addressed interface is stored in /etc/hostname.interface Ex: To make the simple conguration of e1000g0, add 1 more line: 192.168.1.20/24 to /etc/hostname.e1000g0 In case of configure IP interface statically, we need to perform two additional tasks: + Congure routing so that you can connect to systems beyond your local network + Congure the DNS resolver so that your system can translate hostnames to IP addresses 3.1.2.2.9 To deactivate a statically addressed interface Use ifconfig to mark the interface as down: # ifconfig e1000g0 inet down Remove the /etc/hostname.interface le to prevent the interface from being congured on the next boot. 3.1.2.3 Logical interfaces We can associate multiple IP addresses with a single physical interface in OpenSolaris. Doing so requires creating a logical interface which is just an additional address tied to a physical interface. 3.1.2.3.1 Temporarily # ifconfig interface addif ipaddress Ex: Created new logical interface e1000g1:1 # ifconfig e1000g1 addif 10.1.3.17/22 # ifconfig a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=201004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,CoS> mtu 1500 index 2 inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255 e1000g1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 Note that the logical interface is not brought up automatically. To do it: # ifconfig e1000g1:1 up 3.1.2.3.2 Persistently addif command to the hostname.interface le; for example, /etc/hostname.e1000g1 for the preceding conguration: 192.168.1.20/22 up addif 10.1.3.17/22 up 3.1.2.3.3 To de-congure a logical interface #ifconfig interface removeif ipadress Ex: # ifconfig e1000g1 removeif 10.1.3.17 To remove it from the persistent conguration, we must remove the line that adds it from the hostname.interface le.

OpenSolaris Network Commands

Page: 10 of 11

OpenSolaris Network Commands

Page: 11 of 11

Das könnte Ihnen auch gefallen