[已解决][问题]ubuntu 单网卡双IP组建局域网

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
guitar402
帖子: 2
注册时间: 2008-05-12 17:21

[已解决][问题]ubuntu 单网卡双IP组建局域网

#1

帖子 guitar402 » 2008-05-12 17:42

ubuntu7.04 组建实验室局域网
由于实验室条件有限,于是使用单网卡双IP组建局域网
在/etc/network/interfaces
auto lo eth0
iface lo inet loopback

#auto eth0
iface eth0 inet static
address 202.114.2.237
netmask 255.255.255.0
gateway 202.114.2.254

#auto eth0:1
iface eth0:1 inet static
address 192.168.20.2
netmask 255.255.255.0

auto eth1
iface eth1 inet dhcp

auto eth2
iface eth2 inet dhcp

auto ath0
iface ath0 inet dhcp

auto wlan0
iface wlan0 inet dhcp

在终端ping 192.168.20.2 正常,局域网内任一PC ping 192.168.20.2 或202.114.2.237正常
ifconfig -a 也能正常看到eth0:1的相关信息

sysctl.conf文件
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com
net/ipv4/icmp_echo_ignore_broadcasts=1

# the following stops low-level messages on console
kernel.printk = 4 4 1 7

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next line to enable Spoof protection (reverse-path filter)
net.ipv4.conf.default.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.conf.default.forwarding=1

# Uncomment the next line to enable packet forwarding for IPv6
#net.ipv6.conf.default.forwarding=1

且使用sysctl -p激活设备

问题为:服务器(Ubuntu)可以正常上网,但局域网内的PC不能正常上网,请各位帮忙,小弟先谢过了!
上次由 guitar402 在 2008-05-12 19:50,总共编辑 1 次。
guitar402
帖子: 2
注册时间: 2008-05-12 17:21

#2

帖子 guitar402 » 2008-05-12 19:49

在/etc/rc.local下,如下配置

ifconfig eth0:0 192.168.20.2 netmask 255.255.255.0.up
echo 1 | tee /proc/sys/net/ipv4/ip_forward
iptables -A INPUT -i eth0 -d 224.0.0.0/8 -j DROP
iptables -t nat -I POSTROUTING -j SNAT --to-source 202.114.2.237
exit 0

搞定!
ljping51
帖子: 13
注册时间: 2008-04-26 22:42

#3

帖子 ljping51 » 2008-05-16 11:56

谢谢楼主,我试一下。
头像
lhw828
帖子: 2797
注册时间: 2007-03-15 16:58
来自: 湖北武汉
联系:

#4

帖子 lhw828 » 2008-05-16 22:54

蛮高深的问题啊
回复