centos静态ip

Oracle VM VirtualBox配置centos7的网络访问

星期四, 五月 4th, 2017 | linux | 没有评论

在虚拟机中配置centos7的网络

1.启用网络配置 Bridged Adapter桥接模式
bridgedadapter

2.修改配置文件/etc/sysconfig/network-scripts/ifcfg-enp0s3

将ONBOOT=”no”改为yes,
BOOTPROTO=”dhcp”

启用网络 service network restart

3.配置可以工具连接的静态ip地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
#BOOTPROTO=dhcp
BOOTPROTO=NONE  #(修改)
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=enp0s3
UUID=4a42d996-1da5-4ea9-b0f9-88b77615880d
DEVICE=enp0s3
ONBOOT=yes
IPADDR0=192.168.1.188 #(新增)
PREFIX0=24            #(新增)
GATEWAY0=192.168.1.1  #(新增)
DNS1=192.168.1.1      #(新增)
 
service network restart

重启网络即可

Tags: , ,

centos6.4静态ip设置于eth1的问题

星期五, 九月 6th, 2013 | linux | 一条评论

centos6.4的版本安装好,发现系统内只有eth1,而且/etc/sysconfig/network-scripts/下只有ifcfg-eth0文件,虽然可以上网,但无法设置静态IP.

解决方法:vi /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
#SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”08:00:27:f2:31:9b”, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”08:00:27:9d:08:ba“, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth1

上面一个eth0直接注释掉,下面一个eth1改为eth0,记录对应的网卡地址 再编辑ifcfg-eth0 如下

DEVICE=eth0
HWADDR=08:00:27:9D:08:BA
#UUID=accb31df-ac8b-474c-aad8-b1ecd68ad346
NM_CONTROLLED=yes
#BOOTPROTO=dhcp
BOOTPROTO=static
IPADDR=192.168.0.188
GATEWAY=192.168.0.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
DNS1=192.168.0.1

~
网关设置 (上面配置了这里路不用)
在文件vi /etc/sysconfig/network最后一行加入:
GATEWAY=192.168.0.1
/etc/init.d/network restart 重启网络
注:后面要加下DNS1 否则无法上网(oracle VM 安装)
~

Tags: , ,

Search

文章分类

Links

Meta