1.硬件设备,2台pc,其中的一台pc带有两个网卡;
2.软件环境,带有两个网卡的pc上安装了ubuntu9.04,另一台pc上安装了Fedora Core 12;
3.配置网卡和路由:
1)ubuntu9.04上的两个网卡的配置如下:
eth0 Link encap:Ethernet HWaddr 00:1d:7d:cb:d0:bb
inet addr:10.3.49.196 Bcast:10.3.255.255 Mask:255.255.0.0
inet6 addr: fe80::21d:7dff:fecb:d0bb/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:127036 errors:0 dropped:0 overruns:0 frame:0
TX packets:28589 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13375985 (13.3 MB) TX bytes:27462930 (27.4 MB)
Interrupt:253 Base address:0x4000
eth1 Link encap:Ethernet HWaddr 00:0a:eb:f8:80:88
inet addr:192.168.1.198 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20a:ebff:fef8:8088/64 Scope:Link
inet6 addr: 3ffe::c0a8:1c4/64 Scope:Global
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:100550 errors:0 dropped:0 overruns:0 frame:0
TX packets:558 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11373363 (11.3 MB) TX bytes:66500 (66.5 KB)
Interrupt:20 Base address:0xa000
修改/etc/network/interfaces文件
添加如下
iface eth1 inet6 static
address 3ffe::192.168.1.196
netmask 64
iface eth1 inet static
address 192.168.1.198
netmask 24
然后重启机器,就可在eth1上添加ipv6的地址3ffe::192.168.1.196
2)Fedora Core12上网卡的配置如下:
eth0 Link encap:Ethernet HWaddr 00:30:48:21:D3:B8
inet addr:10.3.49.197 Bcast:10.3.255.255 Mask:255.255.0.0
inet6 addr: fe80::230:48ff:fe21:d3b8/64 Scope:Link
inet6 addr: 3ffe::c0a8:1c5/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26647 errors:0 dropped:0 overruns:0 frame:0
TX packets:1046 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2336394 (2.2 MiB) TX bytes:114955 (112.2 KiB)
修改/etc/sysconfig/network-script/icfg-eth0文件,添加
IPV6INIT=yes
PEERDNS=yes
IPV6ADDR=3ffe::192.168.1.197
然后重启机器,就可以在eth0上添加3ffe::192.168.197地址
添加路由:
route add -host 192.168.1.197 gw 10.3.49.196
这样,在ping192.168.1.197时,就把包转到Ubuntu9.04的eth0网卡上
4.在Ubuntu9.04机器上部署naptd软件。
配置如下:
Ataga IPv4/IPv6 NAPT Configuration Maker
(c) 2005 by Lukasz Tomicki <[email protected]>
Do you want to create a new configuration? [Y/n]
Do you want IPv4 addresses from the outside interfaces to be automatically used as part of the NAT pool? [Y/n]
Do you want to configure additional address as part of your NAT pool? [y/N]
Do you want to create a pool of public IPv4 addresses that will allow incoming connections to be dynamically mapped to appropriate IPv6 addresses? [y/N]
y
Enter the first public IPv4 address pool to use.
starting IP: 192.168.1.197
ending IP (inclusive) [192.168.1.197]: 192.168.1.198
Do you want to enter more address pools? [y/N]
Do you want to create static mappings of public IPv4 addresses that will allow incoming connections to reach IPv6 hosts? [y/N]
y
IPv4 address: 192.168.1.197
IPv6 address: 3ffe::192.168.1.197
Do you want to enter another static mapping? [y/N]
Enter the name of the first inside (IPv6) interface that you want NAT-PT to listen on.
interface (eth0 eth1 pan0): eth1
Do you want to enter more interfaces? [y/N]
Enter the name of the first outside (IPv4) interface that you want NAT-PT to listen on.
interface (eth0 eth1 pan0): eth0
Do you want to enter more interfaces? [y/N]
Enter the TCP translation timeout in seconds [86400]:
Enter the UDP translation timeout in seconds [3600]:
Enter the ICMP translation timeout in seconds [30]:
Enter the IPv6 prefix that will be used as the destination for translations.
prefix [2000:ffff::]: 3ffe::
Please enter the IPv4 address of the DNS server you are currently using.
IPv4 DNS server: 202.106.0.20
You can configure hosts for automatic DNS translation by using the DNS server below.
IPv6 DNS Server: 3ffe::ca6a:14
Thank you for choosing Ataga as you IPv4/IPv6 NAT-PT solution.
Setup is now complete. Type 'naptd' to start NAT-PT.
5.测试
在ubuntu机器上运行naptd
在Fedora机器上运行ping 192.168.1.197
在ubuntu机器上运行tcpdump host 10.3.49.197 -i eth0,可以看到icmp包已经到eth0网卡,
在Fedora机器上可以看到:
PING 192.168.1.197 (192.168.1.197) 56(84) bytes of data.
64 bytes from 192.168.1.197: icmp_seq=22 ttl=63 time=21.4 ms
64 bytes from 192.168.1.197: icmp_seq=23 ttl=63 time=1.58 ms
64 bytes from 192.168.1.197: icmp_seq=24 ttl=63 time=1.53 ms
64 bytes from 192.168.1.197: icmp_seq=25 ttl=63 time=1.53 ms
64 bytes from 192.168.1.197: icmp_seq=26 ttl=63 time=1.53 ms
64 bytes from 192.168.1.197: icmp_seq=27 ttl=63 time=1.52 ms
64 bytes from 192.168.1.197: icmp_seq=28 ttl=63 time=1.57 ms
64 bytes from 192.168.1.197: icmp_seq=29 ttl=63 time=1.55 ms
6.结论
naptd开发环境搭建成功。