VMware workstations 11   CentOS 6.6 配置内外网访问


配置 CentOS  6.6 内外网访问

 

虚拟机版本:VMware workstations 11  

系统版本:CentOS  6.6 -2.6.32-504.el6.x86_64

参考:http://co63oc.blog.51cto.com/904636/343080

 

VMware 有四种网络连接方式:

NAT   (NAT模式)

Bridge Adapter  (桥接模式)

Host-only Adapter   (仅主机模式)

自定义模式


默认是NAT连接,但只能访问外网,不能访问主机;

而Host-only Adapter   只能访问主机,不能访问外网;

同时访问外网和内网就是在“网络连接”设置中建立两个网络接口,一个是NAT连接,另一个是Host-only Adapter   连接。



具体操作如下:

1)关机--->“设置”---->添加网络适配器,选择Host-only Adapter   模式---->完成;

2)开机,查看 /etc/udev/rules.d/70-persistent-net.rules 配置文件有两块网卡,然后增加eth1的配置文件。将eth0的复制一份,重启network服务即可;


[root@web-nginx ~]# cat  /etc/udev/rules.d/70-persistent-net.rules

 

# PCI device 0x8086:0x100f (e1000)

SUBSYSTEM=="net",  ACTION=="add", DRIVERS=="?*",  ATTR{address}=="00:0c:29:c9:84:1a", ATTR{type}=="1",  KERNEL=="eth*", NAME="eth0"

 

# PCI device 0x8086:0x100f (e1000)

SUBSYSTEM=="net",  ACTION=="add", DRIVERS=="?*",  ATTR{address}=="00:0c:29:c9:84:24", ATTR{type}=="1",  KERNEL=="eth*", NAME="eth1"

[root@web-nginx ~]# cd  /etc/sysconfig/network-scripts/

[root@web-nginx network-scripts]# ls

ifcfg-eth0             ifdown-post    ifup-ippp    ifup-tunnel

ifcfg-eth2.yvonne.bak  ifdown-ppp     ifup-ipv6    ifup-wireless

ifcfg-lo               ifdown-routes  ifup-isdn     init.ipv6-global

ifdown                 ifdown-sit     ifup-plip    net.hotplug

ifdown-bnep            ifdown-tunnel  ifup-plusb    network-functions

ifdown-eth             ifup           ifup-post    network-functions-ipv6

ifdown-ippp            ifup-aliases   ifup-ppp

ifdown-ipv6            ifup-bnep      ifup-routes

ifdown-isdn            ifup-eth       ifup-sit

[root@web-nginx network-scripts]# cp  ifcfg-eth0 ifcfg-eth1

[root@web-nginx network-scripts]# cat  ifcfg-eth1

DEVICE=eth1

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=dhcp

[root@web-nginx network-scripts]# service  network restart

Shutting down interface eth0:                              [   OK  ]

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth0: 

Determining IP information for eth0...  done.

                                                           [  OK  ]

Bringing up interface eth1: 

Determining IP information for eth1...  done.

                                                            [  OK  ]

[root@web-nginx network-scripts]#  ifconfig

eth0       Link encap:Ethernet  HWaddr  00:0C:29:C9:84:1A 

           inet addr:192.168.116.136   Bcast:192.168.116.255   Mask:255.255.255.0

           inet6 addr: fe80::20c:29ff:fec9:841a/64 Scope:Link

           UP BROADCAST RUNNING MULTICAST   MTU:1500  Metric:1

           RX packets:459 errors:0 dropped:0 overruns:0 frame:0

           TX packets:326 errors:0 dropped:0 overruns:0 carrier:0

           collisions:0 txqueuelen:1000

           RX bytes:42340 (41.3 KiB)  TX  bytes:40565 (39.6 KiB)

 

eth1       Link encap:Ethernet  HWaddr  00:0C:29:C9:84:24 

           inet addr:192.168.142.132   Bcast:192.168.142.255   Mask:255.255.255.0

           inet6 addr: fe80::20c:29ff:fec9:8424/64 Scope:Link

           UP BROADCAST RUNNING MULTICAST   MTU:1500  Metric:1

           RX packets:34 errors:0 dropped:0 overruns:0 frame:0

           TX packets:10 errors:0 dropped:0 overruns:0 carrier:0

           collisions:0 txqueuelen:1000

           RX bytes:3668 (3.5 KiB)  TX  bytes:1236 (1.2 KiB)

 

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:0 errors:0 dropped:0 overruns:0 frame:0

           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

           collisions:0 txqueuelen:0

           RX bytes:0 (0.0 b)  TX bytes:0  (0.0 b)

[root@web-nginx network-scripts]# ip add

1: lo: <LOOPBACK,UP,LOWER_UP> mtu  65536 qdisc noqueue state UNKNOWN

     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

     inet 127.0.0.1/8 scope host lo

     inet6 ::1/128 scope host

        valid_lft forever preferred_lft forever

2: eth0:  <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP  qlen 1000

     link/ether 00:0c:29:c9:84:1a brd ff:ff:ff:ff:ff:ff

     inet 192.168.116.136/24 brd 192.168.116.255 scope global eth0

     inet6 fe80::20c:29ff:fec9:841a/64 scope link

        valid_lft forever preferred_lft forever

3: eth1:  <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP  qlen 1000

     link/ether 00:0c:29:c9:84:24 brd ff:ff:ff:ff:ff:ff

     inet 192.168.142.132/24 brd 192.168.142.255 scope global eth1

     inet6 fe80::20c:29ff:fec9:8424/64 scope link

        valid_lft forever preferred_lft forever

 


你可能感兴趣的:(虚拟机,Adapter,NAT,bridge,双网卡, ,(桥接模式),内外网卡访问,(NAT模式))