centos 網卡配置

來源:互聯網
上載者:User

標籤:blog   os   使用   io   ar   檔案   art   div   cti   

1.查看網路MAC地址
 

 [[email protected] ~]# cat /etc/udev/rules.d/70-persistent-net.rules


  顯示如下資訊
 

 # PCI device 0x15ad:0x07b0 (vmxnet3)   SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:94:04:3c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"  # PCI device 0x15ad:0x07b0 (vmxnet3)  SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:94:53:24", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

  

  eth0:對應第一張網卡,eth1:對就第二張網卡。當前使用eth0連線路由器,eth1保留(伺服器一般用來,串連其它主機)


  2.修改主機名稱
  

[[email protected] ~]# vim /etc/sysconfig/network

  開啟檔案,修改以下內容並儲存

 

NETWORKING=yes      #使用網路HOSTNAME=centos      #設定主機名稱

  3.修改網卡
 

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

  開啟檔案,修改以下內容並儲存

 

 DEVICE=eth0          #對應第一張網卡 TYPE=Ethernet ONBOOT=yes          #是否啟動時運行 NM_CONTROLLED=yes BOOTPROTO=static       #使用靜態IP,而不是由DHCP分配IP DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0"      #名稱 HWADDR=00:50:56:94:04:3C  #必須對應etho是的MAC地址(/etc/udev/rules.d/70-persistent-net.rules) PEERDNS=yes PEERROUTES=yes IPADDR=192.168.2.249     #指定本機IP地址 NETMASK=255.255.255.0    #指定子網路遮罩 GATEWAY=192.168.2.1     #指定網關


  4.修改DNS
 

 [r[email protected] ~]# vim /etc/resolv.conf

  

  開啟檔案,修改以下內容並儲存
  

nameserver 8.8.8.8      #GOOGLE的DNS伺服器nameserver 61.144.56.100      #指定當前城市最近的DNS伺服器(各城市不一樣,上網搜尋)nameserver 192.168.2.1      #指定經路由器上指定的DNS伺服器

  5.重新啟動網路設定
  

[[email protected] ~]#service network restart

  6.重啟

[[email protected] ~]#shutdown -r now

  7.查看當前IP設定

  

[[email protected] ~]# ifconfig

  8.測試是否串連外網

[[email protected] ~]# ping www.baidu.com 

注意:各位正在配置的同學們 千萬不要把字母寫錯了  ipaddr 不要寫成ipadr gateway 千萬不要少個w 樓主就是這麼錯的 哎...

centos 網卡配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.