1. add a virtual network card with the virtual machine hardware configuration. 2. go to linux. In the network configuration, you can see an additional Nic interface eth1. you do not need to set the gateway to set the ip address and MAC address of this Nic interface. set the configuration file: vi/etc/sysconfig/network-scripts/ifcfg-eth1 #...
1. add a virtual network card with virtual machine hardware configuration.
2. go to linux. In the network configuration, you can see an additional Nic interface eth1. you do not need to set the ip address and MAC address of this Nic interface.
Set the configuration file:
Vi/etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE = eth1
ONBOOT = yes
BOOTPROTO = none
HWADDR = 00: 0c: 29: 16: 1b: de/virtual machine assigned to you/
NETMASK = 255.255.255.0
IPADDR = 192.168.2.11
TYPE = Ethernet
USERCTL = no
IPV6INIT = no
PEERDNS = yes
Echo 1>/proc/sys/net/ipv4/ip_forward
Enable route forwarding in linux
Iptables-t nat-a postrouting-o eth0-j MASQUERADE
Configure the nat to connect to the Internet. this eth0 Nic must be connected to the Internet. don't ask me what this command means. I don't know what it means except to instruct nat. this is a test conducted by the company.
For the above two commands, you must re-execute the command every time you enable the virtual machine linux. we recommend that you add the boot script and set it in/etc/rc. local.
The entire network configuration.
Local ip address: 192.168.2.178
Local gateway; 192.168.2.11
Forwarding router: eth1:
Ip: 192.168.2.11
Gateway: no need to configure
Etho:
Ip: 192.168.1.178
Gateway: 192.168.1.38
In this way, my testing platform is ready.
Recently, I am porting the company code, from linux2.4.18 to linux2.6.21. it is the firewall and security gateway code, and it is tested on this virtual gateway.
Function.
2 complaints...
Finally, I realized that many children's shoes have two computers, which makes it easy to work ....
When I call a program, I have to enable this virtual gateway. to use this virtual gateway, I have to use it to access the internet. it was originally used to test my code function, various problems often occur... it is inconvenient to access the Internet .... switching between work and entertainment is often inconvenient .....
Author "programmer"