7.3静态ip linux
2019-04-16 11:44:16 baidu_20729113 阅读数 39

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=105192ae-1a39-42d4-8cf2-4be6c08c81c2
DEVICE=eno16777736
ONBOOT=yes
NETMASK=255.255.255.0
GATEWAY=192.168.81.2
IPADDR=192.168.81.101
DNS1=202.106.46.151
DNS2=114.114.114.114

service network restart

2016-07-11 09:34:52 qq_16590151 阅读数 361

1:查看以太网设备的硬件地址

vi /etc/udev/rules.d/70-persistent-net.rules


2:记录上边文件中eth1 的attr属性


3:修改静态配置文件


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


DEVICE=eth1    //将原来的eth0改为1
HWADDR=00:0c:29:54:da:90     //这里填写上边记录的硬件地址
TYPE=Ethernet
UUID=6bfdb098-42e9-42e4-baff-dbbde126e7b2
ONBOOT=yes
BOOTPROTO=static
NETMASK=255.255.254.0 //这里和下边的IP地址填写你网络对于的值
IPADDR=192.168.161.92


4:重启网络

service network restart


5:如果是虚拟机的话,需要将网络修改为桥接模式

2017-12-07 15:59:06 qq_35476299 阅读数 77

vi   /etc/sysconfig/network-scripts/ifcfg-enp0s3


新增


netmask 和getway可以一样 ipaddr 在局域网中ip


备注: CentOS 7.0默认使用的是firewall作为防火墙

   关闭防火墙:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动


2018-12-05 16:33:18 wuchunlin_it 阅读数 46

TYPE=Ethernet

BOOTPROTO=static

NAME=ens33

DEVICE=ens33

ONBOOT=yes

IPADDR=192.168.100.133

NETMASK=255.255.255.0

GATEWAY=192.168.100.2

DNS1=114.114.114.114

 

 

 

 

 

++++++++++++++++++++++++++++++

centos7

 

TYPE="Ethernet"

BOOTPROTO="static"

DEFROUTE="yes"

PEERDNS="yes"

PEERROUTES="yes"

IPV4_FAILURE_FATAL="no"

IPV6INIT="yes"

IPV6_AUTOCONF="yes"

IPV6_DEFROUTE="yes"

IPV6_PEERDNS="yes"

IPV6_PEERROUTES="yes"

IPV6_FAILURE_FATAL="no"

IPV6_ADDR_GEN_MODE="stable-privacy"

NAME="ens33"

UUID="c9159237-ac16-4b44-98a9-b31959183599"

DEVICE="ens33"

ONBOOT="yes"

IPADDR0=192.168.100.101

PREFIXO0=24

GATEWAY0=192.168.100.2

DNS1=8.8.8.8

DNS2=8.8.4.4

2019-05-07 14:25:11 qq_26486949 阅读数 32

linux配置静态IP

前提请确认网络连接方式为:桥接

修改网卡eth0

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

++++++++++++++++++++++++++++++++

DEVICE="eth0"
BOOTPROTO="static" #将原来的值“dhcp”改为“static”
HWADDR="00:0C:29:F2:4E:96"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="b68b1ef8-13a0-4d11-a738-1ae704e6a0a4"


IPADDR=192.168.1.16    #你需要定义的IP地址

#以下两个的值如果不清楚的话,可以打开你本地的电脑,

--》控制面板\所有控制面板项\网络和共享中心\本地连接\详细信息
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.1.1    #默认网关,
 

++++++++++++++++++++++++++++++++

保存退出

重启网络服务

service network restart

检查一下状态

ifconfig -a

+++++++++++++++++++++++++++++++++

eth0      Link encap:Ethernet  HWaddr 00:0C:29:F2:4E:96  
          inet addr:192.168.1.16  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fef2:4e96/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17017 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9586 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7803412 (7.4 MiB)  TX bytes:1613751 (1.5 MiB)

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:16436  Metric:1
          RX packets:21844 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2042507 (1.9 MiB)  TX bytes:2042507 (1.9 MiB)

+++++++++++++++++++++++++++++++++

 

到了这里,请ping一下外网

ping baidu.com

我遇到两个情况:

1)ping通了,oh yeah!

2)报错:ping:unknow host baidu.com

  好吧,我的解决方法是:

  dhclient

  敲了这个命令后,再ping一次

  ---------------------------------

  PING baidu.com (180.149.132.47) 56(84) bytes of data.
  64 bytes from 180.149.132.47: icmp_seq=1 ttl=54 time=38.3 ms
  64 bytes from 180.149.132.47: icmp_seq=2 ttl=54 time=38.7 ms
  64 bytes from 180.149.132.47: icmp_seq=3 ttl=54 time=49.7 ms
  64 bytes from 180.149.132.47: icmp_seq=4 ttl=54 time=38.1 ms
  64 bytes from 180.149.132.47: icmp_seq=5 ttl=54 time=37.9 ms
  64 bytes from 180.149.132.47: icmp_seq=6 ttl=54 time=38.3 ms

  ---------------------------------

  正我是这样解决的

  还有人是这样:配置静态IP之后reboot

 

 还有一个情况就是,ping 外网IP可以,但是无法ping域名。我的解决办法是:设置DNS

vim /ect/resolv.conf

nameserver 114.114.114.114 //这个值我是在本地连接的状态信息里找到的

保存之后退出,再ping!

Linux设置静态ip

阅读数 229

Linux设置静态ip

阅读数 35

链接

博文 来自: Kazer7

Linux静态IP设置

阅读数 149

linux 静态IP配置

阅读数 342

Linux静态IP配置

阅读数 131

没有更多推荐了,返回首页