|
一、背景:
linux (ubuntu) 双网卡服务器作WEB、路由、DHCP服务器。
eth2对外:10.1.1.244/254
eth3对内:192.178.1.254/20
内网说明:192.178.0.1/20 gw:192.178.1.254
XEN-SERVER:192.178.1.100/20 管理端口443,建立虚拟机,网络模式为桥接。
二、网络配置方案:
内网通过NAT方式访问外网,XEN-SERVER通过10.1.1.244:8443管理。
三、配置说明:
1.244机器开启iptables并作以下配置
#清除filter表规则
1
2
3
| iptables -F
iptables -X
iptables -Z
|
#清除nat表规则
1
2
3
| iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
|
#nat 转发
1
| iptables –t nat –A POSTROUNTING –s 192.178.0.0/20 –o eht2 –j MASQUERADE
|
#XENSERVER的管理端口映射
1
| iptables –t nat –A PREROUTING –i eth2 –p tcp –dport 8443 –j DNAT–to-destination 192.178.1.100:443
|
2.保存iptables 配置
#创建/etc/iptables.up.rules 文件,并修改权限
1
2
| vim /etc/iptables.up.rules
chmod 777 iptables.up.rules
|
#将iptables配置保存
1
| iptables-save > /etc/iptables.up.rules
|
#找到网络配置文件
1
| vim /etc/network/interfaces
|
#外网eht2后面添加,随网卡启动生效
1
| pre-up iptables-restore < /etc/iptables.up.rules
|
附iptables.up.rules 注意几个ACCEPT上面没说,我默认是全放开的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| *nat
:PREROUTING ACCEPT [632:40162]
:INPUT ACCEPT [158:11837]
:OUTPUT ACCEPT [1:328]
:POSTROUTING ACCEPT [1:328]
-A PREROUTING -i eth2 -p tcp -m tcp --dport 8443 -j DNAT --to-destination 192.168.1.100:443
-A POSTROUTING -s 192.178.0.0/20 -o eth2 -j MASQUERADE
COMMIT
# Completed on Mon Mar 30 10:55:20 2015
# Generated by iptables-save v1.4.12 on Mon Mar 30 10:55:20 2015
*filter
:INPUT ACCEPT [60769:14812609]
:FORWARD ACCEPT [32923:35214235]
:OUTPUT ACCEPT [52652:9629979]
COMMIT
|
|
|
|
|
|
|
|