Linux Basic network Settings

Source: Internet
Author: User
Tags nameserver nslookup fully qualified domain name

Linux Basic network Settings

Basic information of network, setting up basic information of network; DHCP Automatic management network basic information

1. View of the basic information of the network:

Ip/netmask/gateway/dns/mac/hostname/hosts Network basic information

1) View ip/netmask/mac information: IFCONFIG/IP

IFCONFIG-A # #查看所有激活与非激活的网卡信息

Ifconfig # #只查看激活的网卡信息

Ifconfig eth0 # #查看单个网卡信息

IP A # #查看ip地址等信息

IP L # #查看网卡连接情况

2) View DNS:

cat/etc/resolv.conf # #查看dns

Search Domain # #在那个域中

NameServer DNS server address # #使用dns服务器地址, there can be 3

3) View hostname, Hosts file

Hostname # #查看主机名

Cat/etc/hosts # #本地的域名和IP对应记录文件

4) View Gateway:

IP R # #查看路由表, including default route

Route-n = = Netstat-nr # #查看路由表

Management of the Windows routing table:

Route Print # #查看路由表

Route add 10.10.10.0 Mask 255.255.255.0 192.168.10.1 # #添加路由

Route Delete 10.10.10.0 # #删除路由

5) test Network: Ping/nslookup/traceroute

Ping-c 4 ip/Domain ##-c 4 send 4 packages

ping-i eth0 ip/Domain # #多网卡时指定源

nslookup = = Dig FQDN # #测试dns, FQDN refers to fully qualified domain name

Traceroute target ip/Domain # #路由跟踪

2. Modify the network parameters:

1) changes that are in effect temporarily:

A. Change the IP address:

Ifconfig eth0 192.168.10.100/24 Up # #临时设置ip地址, and up can also be used down

Ifconfig eth0:0 10.10.10.95/24 Up # #设置虚拟网卡, that is, a mesh set multiple addresses, the first starting from 0

IP A # #验证, can also be used Ifconfig

B. Temporarily set up routes and hosts:

Man Route--search Example reference

Route add-net 192.168.10.0 netmask 255.255.255.0 GW 10.10.10.1 # #添加路由

Route add default GW 10.10.10.1 # #添加默认网关

Route del-net 192.168.10.0 netmask 255.255.255.0 # #删除路由

Route del Default # #删除默认网关

IP R # #查看验证

Hostname www.linuxyy.cn # #临时修改主机名

2) changes that are permanently in effect:

A. Modify Ip/netmask/gateway/dns

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device= "Eth0" # #网卡的名称

Hwaddr= "MAC Address"

Nm_controlled= "No" # #禁用NM网络管理机制

Bootproto=static # #设置启动协议为静态, if DHCP indicates automatic acquisition

Onboot= "Yes" # #设置网卡为可以激活

ipaddr=10.10.10.95 # #设置ip地址

netmask=255.255.255.0 # #设置子网掩码

gateway=10.10.10.1 # #设置默认网关

dns1=202.106.0.20 # #设置该网卡的dns服务器

: Wq

/etc/init.d/network Restart # #重启网络服务

Chkconfig Network on # #设置为开机启动

Chkconfig NetworkManager off # #禁止NM开机启动

IP A # #验证

Cat/etc/resolv.conf

IP r

Vi/etc/resolv.conf # #全局生效, which is valid for all network cards, can be set to a maximum of 3

Search linuxyy.cn

NameServer 10.10.10.95

NameServer 202.106.0.20

NameServer 8.8.8.8

: Wq


B. Set the static hostname:

Vi/etc/sysconfig/network

hostname=www.linuxyy.cn # #www是主机名, linuxyy.cn domain suffix, FQDN (fully qualified domain name) = hostname + domain suffix

: Wq

Reboot # #重启后生效

Hostname # #验证


C. Set up a route entry that is permanently active:

Vi/etc/rc.local

Route add-net 192.168.10.0 netmask 255.255.255.0 GW 10.10.10.1 # #添加该路由条目

: Wq

Source/etc/rc.local # #执行文件中的命令,/etc/rc.local is the user profile that was last executed during system startup


D. Set the Hosts file:/etc/hosts implementation hostname and IP corresponding to the equivalent of local DNS, if large enough can not need a DNS server to be able to surf the internet, generally used to speed up network access, or avoid DNS hijacking and DNS pollution, to achieve fast and secure Internet access.

Vi/etc/hosts

10.10.10.95wwwwww.linuxyy.cn

: Wq

Ping www.linuxyy.cn


E. Disabling IPv6:

Vi/etc/sysconfig/network

Ipv6init=no

: Wq

Vi/etc/modprobe.d/disable-ipv6.conf

Install Ipv6/bin/true

: Wq

IP A # #查看有ipv6

Reboot

IP A # #无ipv6


This article is from the "11628205" blog, please be sure to keep this source http://11638205.blog.51cto.com/11628205/1982390

Linux Basic network Settings

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.