溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

linux的網(wǎng)絡(luò)參數(shù)怎么配置

發(fā)布時(shí)間:2022-04-16 15:04:05 來(lái)源:億速云 閱讀:176 作者:iii 欄目:編程語(yǔ)言

本篇內(nèi)容主要講解“l(fā)inux的網(wǎng)絡(luò)參數(shù)怎么配置”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“l(fā)inux的網(wǎng)絡(luò)參數(shù)怎么配置”吧!

主要用途:
1、查看網(wǎng)絡(luò)接口設(shè)置: ifconfig –a或ifconfig 網(wǎng)絡(luò)接口 –a
2、網(wǎng)絡(luò)配置 ifconfig  網(wǎng)絡(luò)接口  [add/del]  ip地址  netmask  子網(wǎng)掩碼 例:ifocnfig eth0 10.2.3.4 [netmask 255.255.255.0]
3、網(wǎng)絡(luò)接口的激活/關(guān)閉 格式:ifconfig 網(wǎng)絡(luò)接口 up/down
配置dns
建立/etc/resolv.conf文件,在里面寫入dns服務(wù)器地址
配置主機(jī)名
配置/etc/sysconfig/network文件,同時(shí)使用hostname 修改主機(jī)名
使用例子:

復(fù)制代碼 代碼如下:

[root@twin0898 sysconfig]# cat network
network          networking/      network-scripts/
[root@twin0898 sysconfig]# cat network
networking=yes
gateway=125.39.149.1
hostname=twin0898
networking_ipv6=no

通用格式:
1、到網(wǎng)絡(luò)的網(wǎng)關(guān) route  add/delete  -net  目標(biāo)網(wǎng)絡(luò)  netmask  掩碼   gw  網(wǎng)關(guān)地址  [dev  網(wǎng)絡(luò)接口]
2、到單一主機(jī)的網(wǎng)關(guān) route  add/delete  -host  目標(biāo)主機(jī)  gw  網(wǎng)關(guān)地址  [dev  網(wǎng)絡(luò)接口]
3、添加默認(rèn)網(wǎng)關(guān): route  add  default  gw  網(wǎng)關(guān)地址 檢查主機(jī)路由表:route,netstat -nr
// 總結(jié)如下:
1、網(wǎng)絡(luò)配置檢查:ifconfig -a
2、連通性檢查:ping、traceroute
3、路由表檢查:route或netstat –nr
4、dns客戶端運(yùn)行狀態(tài)檢查:nslookup
// 使用例子如下
// ifconfig -a

復(fù)制代碼 代碼如下:

root@cinematest2:/usr/local/jdk# ifconfig -a
eth0      link encap:ethernet  hwaddr b8:ac:6f:38:10:c6 
          inet addr:192.168.232.127  bcast:192.168.232.255  mask:255.255.255.0
          inet6 addr: fe80::baac:6fff:fe38:10c6/64 scope:link
          up broadcast running multicast  mtu:1500  metric:1
          rx packets:42918159 errors:0 dropped:0 overruns:0 frame:0
          tx packets:40893832 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          rx bytes:30644395811 (30.6 gb)  tx bytes:30932951131 (30.9 gb)
          interrupt:16

lo        link encap:local loopback 
          inet addr:127.0.0.1  mask:255.0.0.0
          inet6 addr: ::1/128 scope:host
          up loopback running  mtu:65536  metric:1
          rx packets:917 errors:0 dropped:0 overruns:0 frame:0
          tx packets:917 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          rx bytes:81417 (81.4 kb)  tx bytes:81417 (81.4 kb)

// ping vip.jb51.net

復(fù)制代碼 代碼如下:

ping movie.kankan.co.sandai.net (114.80.189.60) 56(84) bytes of data.
64 bytes from 114.80.189.60: icmp_seq=1 ttl=54 time=31.2 ms
64 bytes from 114.80.189.60: icmp_seq=2 ttl=54 time=29.9 ms
64 bytes from 114.80.189.60: icmp_seq=3 ttl=54 time=31.1 ms
64 bytes from 114.80.189.60: icmp_seq=4 ttl=54 time=30.5 ms
64 bytes from 114.80.189.60: icmp_seq=5 ttl=54 time=31.4 ms
64 bytes from 114.80.189.60: icmp_seq=6 ttl=54 time=32.6 ms
64 bytes from 114.80.189.60: icmp_seq=7 ttl=54 time=30.8 ms
64 bytes from 114.80.189.60: icmp_seq=8 ttl=54 time=30.9 ms
64 bytes from 114.80.189.60: icmp_seq=9 ttl=54 time=32.0 ms
64 bytes from 114.80.189.60: icmp_seq=10 ttl=54 time=31.3 ms
64 bytes from 114.80.189.60: icmp_seq=11 ttl=54 time=31.3 ms
64 bytes from 114.80.189.60: icmp_seq=12 ttl=54 time=30.3 ms

--- movie.kankan.co.sandai.net ping statistics ---
12 packets transmitted, 12 received, 0% packet loss, time 11004ms
rtt min/avg/max/mdev = 29.954/31.148/32.608/0.704 ms

// netstat -nr

復(fù)制代碼 代碼如下:

root@cinematest2:/usr/local/jdk# netstat -nr
kernel ip routing table
destination     gateway         genmask         flags   mss window  irtt iface
0.0.0.0         192.168.232.2   0.0.0.0         ug        0 0          0 eth0
192.168.232.0   0.0.0.0         255.255.255.0   u         0 0          0 eth0

// nslookup vip.jb51.net

復(fù)制代碼 代碼如下:

root@cinematest2:/etc# nslookup vip.jb51.net
server:         192.168.8.150
address:        192.168.8.150#53

non-authoritative answer:
vip.jb51.net  canonical name = movie.jb51.net.
movie.jb51.net        canonical name = movie.kankan.co.sandai.net.
name:   movie.kankan.co.sandai.net
address: 114.80.189.60
name:   movie.kankan.co.sandai.net
address: 119.147.41.209

到此,相信大家對(duì)“l(fā)inux的網(wǎng)絡(luò)參數(shù)怎么配置”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI