How to configure IP addresses for Linux

Source: Internet
Author: User
Tags file copy uuid nslookup to domain traceroute command

Ifconfig command temporarily configures IP address

Ifconfig command: View and configure network status commands

// 查看当前网络状态#ifconfig// 配置网卡的临时生效的IP地址#ifconfig eth0 192.168.0.200 netmask 255.255.255. 0// 配置网关default192.168.0.1
Setup tool permanently configures IP address

The Redhat proprietary graphical tool setup makes permanent configuration of IP addresses.

// 使用setup工具配置,启用DHCP时选择*,不启用为空格,配置静态IP;#setup// 重启网卡生效#service network restart
Modify the network configuration file Ubuntu system static IP address configuration
// 配置静态IP文件/etc/network/interfaces#vi /etc/network/interfacesstatic192.168.0.252192.168.0.1255.255.255.0#network 192.168.0.0#broadcast 192.168.0.255// 重启网卡使配置生效#/etc/init.d/networking restart 
Redhat related system static IP address configuration
//Modify the configuration file for Nic eth0 to open ifcfg-eth0 file#vi/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=Eth0//network card device nameBootproto=None                  //Whether IP is automatically acquired (none, Static, DHCP), where none and static represent the IP address assigned manuallyHWADDR=xx:0C: in: -: C4: the        //MAC addressNm_controlled=Yes//Can be managed by the Network Manager graphical management toolOnboot=Yes//Whether to start with the network service, eth0 effective, no when ifconfig see the eth0 network card IP informationTYPE=Ethernet//Type is EthernetUuid="Xxxxxx-xxxx ..."           //Unique identification codeIPAddr=192.168. 0. 252            //IP addressNETMASK=255.255. 255. 0           //Subnet maskGatway=192.168. 0. 1              //GatewayDNS1=202.106. 0.               //DNSIpv6init=No//IPV6 not enabledUserctl=No//Do not allow non-root users to control this network card

Note: The virtual machine system can be cloned to get other systems, in the same network can not access the Internet, it is likely due to its network card UUID caused by the same conflict.
Solution:

//modify UUID   #vi /etc/sysconfig/network-scripts /ifcfg-eth0  //Delete mac address   #rm  Span class= "Hljs-attribute" >-rf /etc/udev/rules D/70  -persistent  -net   Rules//delete network card and MAC address binding file   #shutdown  -r  now//restart system   
// 主机名配置#vi /etc/sysconfig/networkNETWORKING=yes                  // 网卡是否在工作HOSTNAME=localhost.localdomain  // 在linux下hostname已经没有windows下那么重要了,可以修改,必须重启计算机才能生效#hostname                       // 查看hostname#hostname imooc                 // 临时修改hostname
// DNS配置文件#vi /etc/resolv.conf202.106.0.20search localhost                
Graphical interface Configuration IP address

Linux server does not have a graphical interface, the general desktop version of Linux can be configured through the graphical interface IP address, this is more similar to the Windows system.

Linux Network Command network Environment View Command ifconfig command

View and configure network status commands

Ifdown and Ifup commands

Disabling and enabling network card commands

#ifdown eth0 #ifup eth0
Netstat command

Nestat: View network connection Status
Options
-T: List TCP protocol ports
-U: List UDP protocol ports
-N: Not applicable to domain name and service name, but with IP address and port number
-L: Only the Listening State Network service is listed
-A: List all network connections

// 查看当前网络TCP监听和UDP连接状态#netstat-tuln// 查看当前正在连接TCP连接个数#netstat-an|grep ESTABLISHED|-l
To view the commands for a gateway
// 查看网关#netstat-rn            // 最后一条为网关#route-n
Domain Name Resolution command
// 查看本机DNS服务器#nslookup >server                 // 输入server// 进行域名与IP地址解析#nslookup 主机名/IP
Network Test Command ping command

Probe the network status of a specified IP or domain name

#ping 192.168.0.253 // CTRL+C终止ping// ping 4次#ping 192.168.0.253  -c 4 
Telnet command

Remote management and port probing commands
Like Telnet and FTP, all packets are delivered in clear text, including the user name and password

// telnet做端口探测#telnet 192.168.0.252 80  // 端口开启,连接成功,使用ctrl+] 回到telnet命令输入 quit退出// 端口关闭,连接失败,提示无法打开连接
Traceroute command
// 使用icmp进行远程探测,有些节点显示 ***, 因为这些节点禁止ping#traceroute www.imooc.com#traceroute —n 62.123.23.2 // 使用IP,不使用域名,速度更快
wget command

Download command

#wget 文件uri
tcpdump command

Options
-i specifies the NIC interface
-nn the domain name and service in the packet to IP and port
-X Display packet contents in 16 binary and ASCII code
PORT Specifies the listening port

// 抓取ftp连接#tcp-i-nnX21
Remote Login SSH protocol principle

Remote management Specifies the Linux server: SSH user name @ip

Download file: SCP [-r] User name @ip: File path Local Path

Upload file: SCP [-r] Local file user name @ip: Upload path

Reference: SSH use

SECURECRT Remote management Tools

Charge tool, but easy to use, data transmission is encrypted, very safe.

Xshell Tools and WinSCP File transfer tools

Xshell has a free version, powerful, recommended to use.
WinSCP Secure file Copy tool, easy to use, recommended.

Reference

Network management of Web Linux in Mu-class network

How to configure IP addresses for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.