『壹』 linux 怎樣設置外網ip、網關、掩碼
1、命令行使用vi編輯器打開網卡配置文件ifcfg-eth0:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
『貳』 Linux中,怎樣永久修改IP和子網掩碼
linux中永久修改ip和子網掩碼,可以用命令也可以直接到文件里修改。這里推薦直接到文件中修改。
1、進入網卡配置文件 vi /etc/sysconfig/network-scripts/ifcfg-ethN (ifcfg-ethN是你要修改的網卡,可以用ifconfig查看你要修改的網卡)
2、進入文件進行編輯,更改其中的ip 和子網掩碼。
3、重啟網路服務,並用ifconfig 查看網卡信息。
service network restart
ifconfig
『叄』 在Linux中要臨時配置網卡的IP地址和掩碼如何實現要永久配置網卡的IP地址和掩碼如何實現
在linux當中,第一塊網卡的設備名是eth0,文件是ifcfg-eth0,保存在了/etc/sysconfig/network-scripts/這個目錄下面
1. 臨時配置:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
2. 永久生效:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
打開這個文件後,裡面寫入以下內容:
DEVICE=eth0 定義設備名稱
ONBOOT=yes 開機是否自動激活
BOOTPROTO=static 獲得IP的方式
IPADDR=192.168.1.1 IP地址
NETMASK=255.255.255.0 子網掩碼
GATEWAY=192.168.1.100 網關(根據需求,不一定要寫)
然後保存退出,重啟服務 service network restart
注意: 這裡面的BOOTPROTO=static意思是IP地址為手動配置,那麼後面的內容也要寫了,如果你是自動獲得IP地址,那麼把這段改為BOOTPROTO=dhcp,然後把後面內容全部刪除就可以了,同樣也要重啟服務。
提示: 注意大小寫。
『肆』 linux 查看IP的子網掩碼
樓主,你暈啥,你和別人的主機又不在一個區域網內,你知不知道他的子網掩碼對你沒有任何關系,子網掩碼純粹是用在區域網內部子網劃分的時候才有意義的。所以對區域網外部的人來說,完全沒有任何意義。
就算你和其他主機在同一個區域網內(但不同子網),你也不需要知道別人的掩碼,你只要知道在自己所在的區域網內,IP/掩碼應該設置成多少就行了,就能保證你和其他主機互聯,而根本不需要知道其他主機的掩碼。
『伍』 Linux怎麼設置IP,子網掩碼和網關
linux一般使用ifconfig命令修改linux主機的ip、網關或子網掩碼。 1.命令格式: ifconfig [網路設備] [參數] 2.命令功能: ifconfig 命令用來查看和配置網路設備。當網路環境發生改變時可通過此命令對網路進行相應的配置。 3.命令參數: up 啟動指定網路設備/網卡。 down 關閉指定網路設備/網卡。該參數可以有效地阻止通過指定介面的IP信息流,如果想永久地關閉一個介面,我們還需要從核心路由表中將該介面的路由信息全部刪除。 arp 設置指定網卡是否支持ARP協議。 -promisc 設置是否支持網卡的promiscuous模式,如果選擇此參數,網卡將接收網路中發給它所有的數據包 -allmulti 設置是否支持多播模式,如果選擇此參數,網卡將接收網路中所有的多播數據包 -a 顯示全部介面信息 -s 顯示摘要信息(類似於 netstat -i) add 給指定網卡配置IPv6地址 del 刪除指定網卡的IPv6地址 <硬體地址> 配置網卡最大的傳輸單元 mtu<位元組數> 設置網卡的最大傳輸單元 (bytes) netmask<子網掩碼> 設置網卡的子網掩碼。掩碼可以是有前綴0x的32位十六進制數,也可以是用點分開的4個十進制數。如果不打算將網路分成子網,可以不管這一選項;如果要使用子網,那麼請記住,網路中每一個系統必須有相同子網掩碼。 tunel 建立隧道 dstaddr 設定一個遠端地址,建立點對點通信 -broadcast<地址> 為指定網卡設置廣播協議 -pointtopoint<地址> 為網卡設置點對點通訊協議 multicast 為網卡設置組播標志 address 為網卡設置IPv4地址 txqueuelen<長度> 為網卡設置傳輸列隊的長度 4.使用實例: 實例1:顯示網路設備信息(激活狀態的) 命令: ifconfig 輸出: [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20 inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0 TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:68 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB) 說明: eth0 表示第一塊網卡, 其中 HWaddr 表示網卡的物理地址,可以看到目前這個網卡的物理地址(MAC地址)是 00:50:56:BF:26:20 inet addr 用來表示網卡的IP地址,此網卡的 IP地址是 192.168.120.204,廣播地址, Bcast:192.168.120.255,掩碼地址Mask:255.255.255.0 lo 是表示主機的回壞地址,這個一般是用來測試一個網路程序,但又不想讓區域網或外網的用戶能夠查看,只能在此台主機上運行和查看所用的網路介面。比如把 HTTPD伺服器的指定到回壞地址,在瀏覽器輸入 127.0.0.1 就能看到你所架WEB網站了。但只是您能看得到,區域網的其它主機或用戶無從知道。 第一行:連接類型:Ethernet(乙太網)HWaddr(硬體mac地址) 第二行:網卡的IP地址、子網、掩碼 第三行:UP(代表網卡開啟狀態)RUNNING(代表網卡的網線被接上)MULTICAST(支持組播)MTU:1500(最大傳輸單元):1500位元組 第四、五行:接收、發送數據包情況統計 第七行:接收、發送數據位元組數統計信息。 實例2:啟動關閉指定網卡 命令: ifconfig eth0 up ifconfig eth0 down 輸出: 說明: ifconfig eth0 up 為啟動網卡eth0 ;ifconfig eth0 down 為關閉網卡eth0。ssh登陸linux伺服器操作要小心,關閉了就不能開啟了,除非你有多網卡。 實例3:為網卡配置和刪除IPv6地址 命令: ifconfig eth0 add 33ffe:3240:800:1005::2/64 ifconfig eth0 del 33ffe:3240:800:1005::2/64 輸出: 說明: ifconfig eth0 add 33ffe:3240:800:1005::2/64 為網卡eth0配置IPv6地址; ifconfig eth0 add 33ffe:3240:800:1005::2/64 為網卡eth0刪除IPv6地址; 練習的時候,ssh登陸linux伺服器操作要小心,關閉了就不能開啟了,除非你有多網卡。 實例4:用ifconfig修改MAC地址 命令: ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE 輸出: [root@localhost ~]# ifconfig eth0 down //關閉網卡 [root@localhost ~]# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址 [root@localhost ~]# ifconfig eth0 up //啟動網卡 [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:AA:BB:CC:DD:EE inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0 TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:68 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB) [root@localhost ~]# ifconfig eth0 hw ether 00:50:56:BF:26:20 //關閉網卡並修改MAC地址 [root@localhost ~]# ifconfig eth0 up //啟動網卡 [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:20 inet addr:192.168.120.204 Bcast:192.168.120.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0 TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:68 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB) 說明: 實例5:配置IP地址 命令: 輸出: [root@localhost ~]# ifconfig eth0 192.168.120.56 [root@localhost ~]# ifconfig eth0 192.168.120.56 netmask 255.255.255.0 [root@localhost ~]# ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255 說明: ifconfig eth0 192.168.120.56 給eth0網卡配置IP地:192.168.120.56 ifconfig eth0 192.168.120.56 netmask 255.255.255.0 給eth0網卡配置IP地址:192.168.120.56 ,並加上子掩碼:255.255.255.0 ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255 /給eth0網卡配置IP地址:192.168.120.56,加上子掩碼:255.255.255.0,加上個廣播地址: 192.168.120.255 實例6:啟用和關閉ARP協議 命令: ifconfig eth0 arp ifconfig eth0 -arp 輸出: [root@localhost ~]# ifconfig eth0 arp [root@localhost ~]# ifconfig eth0 -arp 說明: ifconfig eth0 arp 開啟網卡eth0 的arp協議; ifconfig eth0 -arp 關閉網卡eth0 的arp協議; 實例7:設置最大傳輸單元 命令: ifconfig eth0 mtu 1500 輸出: [root@localhost ~]# ifconfig eth0 mtu 1480 [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1480 Metric:1 RX packets:8712395 errors:0 dropped:0 overruns:0 frame:0 TX packets:36631 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:597062089 (569.4 MiB) TX bytes:2643973 (2.5 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:9973 errors:0 dropped:0 overruns:0 frame:0 TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB) [root@localhost ~]# ifconfig eth0 mtu 1500 [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BF:26:1F inet addr:192.168.120.203 Bcast:192.168.120.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8712548 errors:0 dropped:0 overruns:0 frame:0 TX packets:36685 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:597072333 (569.4 MiB) TX bytes:2650581 (2.5 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:9973 errors:0 dropped:0 overruns:0 frame:0 TX packets:9973 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:518096 (505.9 KiB) TX bytes:518096 (505.9 KiB) [root@localhost ~]# 說明: 設置能通過的最大數據包大小為 1500 bytes 備註:用ifconfig命令配置的網卡信息,在網卡重啟後機器重啟後,配置就不存在。要想將上述的配置信息永遠的存的電腦里,那就要修改網卡的配置文件了。
『陸』 Linux可以查看ip網關和子網掩碼嗎
cmd里IPCONFIG/ALL
host
name=主機名
IP
ADDRESS=IP地址
SUBNET
MAST=子網掩碼
DEFAULT
GATEWAY=網關
如果有ADSL或者其他連接的上面有顯示自己看是什麼連接
一般的都是有一個本地連接如果有ADSL那就有個PPP的那個
『柒』 主機ip子網掩碼 默認網關最後不是0,1。 linux的ip怎麼設置
linux設置IP有4種
我就記得3種了—
—!
ifconfig
eth0
192.168.1.1
255.255.255.0
這個是臨時配置第一張網卡,網卡重啟後,失效
setup
這個命令可以設置N多東西,包括網卡,可以永久配置網卡
還有自己手動修改IP文件在
/etc/sysconfig/network-scripts/ifcfg-eth0.conf (應該是這個吧,有點模糊了。。。),然後用VI編輯器修改,這種方法不推薦你使用,貌似對新手有困難
『捌』 如何用linux命令修改linux主機ip網關子網掩碼
ifconfig eth0 192.168.1.101 netmask 255.255.255.0 broadcast 255.255.255.255 配置ip
route add default gw 192.168.1.100 添加網關
更加詳細信息查看我的空間,這里:http://hi..com/cprime010/blog/item/452ce0f95a05681a6c22eb2b.html