openvz pppoe
Трябва да NAT-неш VPS машината, така че пакетите излизащи от нея да се скриват зад IP адреса на реалната ти машина.
Добави това като root и трябва да имаш пинг:
iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
За да можеш да браузваш трябва да си настроиш DNS-а във виртуалната машина.
Ето interfaces на виртуалната машина
# Auto generated lo interface
auto lo
iface lo inet loopback
# Auto generated venet0 interface
auto venet0
iface venet0 inet static
address 127.0.0.1
netmask 255.255.255.255
broadcast 0.0.0.0
up route add -net 192.0.2.1 netmask 255.255.255.255 dev venet0
auto venet0:0
iface venet0:0 inet static
address 192.168.0.5
netmask 255.255.255.255
broadcast 0.0.0.0
gateway 192.0.2.1
а това на реалната машина
root@shemet:~$ cat /etc/network/interfaces
auto lo eth0 eth1
iface lo inet loopback
iface eth0 inet static
address 1.2.3.4
netmask 255.255.255.0
hwaddress ether 00:17:31:29:22:80
auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up
post-up /usr/sbin/ipmasq
provider dsl-provider
iface eth1 inet static
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
ако успея да сменя netmask и gateway на виртуалната машина може би ще има интернет но аз във vzctl не виждам такава команда с която да се сменят някаква идея?
Напиши следните команди в хоста и във виртуалната машина и ми ги прати:
ifconfig -a
route -n
На реалната
root@shemet:~$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:17:31:29:22:80
inet addr:1.2.3.4 Bcast:1.2.3.255 Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fe29:2280/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1337569675 errors:0 dropped:0 overruns:0 frame:0
TX packets:2062175394 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:312759927 (298.2 MiB) TX bytes:1953442844 (1.8 GiB)
Interrupt:16
eth1 Link encap:Ethernet HWaddr 4c:00:10:3b:a2:f8
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::4e00:10ff:fe3b:a2f8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:173157695 errors:0 dropped:0 overruns:0 frame:0
TX packets:107198321 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3133564046 (2.9 GiB) TX bytes:1402280264 (1.3 GiB)
Interrupt:16 Base address:0xdc00
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:16436 Metric:1
RX packets:1685264 errors:0 dropped:0 overruns:0 frame:0
TX packets:1685264 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:169149201 (161.3 MiB) TX bytes:169149201 (161.3 MiB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:178.239.234.63 P-t-P:10.0.0.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:23348 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2760949 (2.6 MiB) TX bytes:54 (54.0 B)
ppp1 Link encap:Point-to-Point Protocol
inet addr:178.239.230.240 P-t-P:10.0.0.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:204072101 errors:0 dropped:0 overruns:0 frame:0
TX packets:375045399 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:3386737537 (3.1 GiB) TX bytes:808840825 (771.3 MiB)
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:111 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:8940 (8.7 KiB) TX bytes:0 (0.0 B)
root@shemet:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
10.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp1
192.168.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 venet0
1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp1
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
на виртуалната
root@unborn:/# ifconfig -a
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:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:300 (300.0 B) TX bytes:300 (300.0 B)
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:111 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:8940 (8.7 KiB)
venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:192.168.0.5 P-t-P:192.168.0.5 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
root@unborn:/# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.0.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 venet0
0.0.0.0 192.0.2.1 0.0.0.0 UG 0 0 0 venet0
root@unborn:/# ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
няма a пуснах няколко пинга от хоста и това е резултата
root@shemet:~$ ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
From 213.231.131.105 icmp_seq=1 Destination Net Unreachable
From 213.231.131.105 icmp_seq=2 Destination Net Unreachable
From 213.231.131.105 icmp_seq=3 Destination Net Unreachable
From 213.231.131.105 icmp_seq=4 Destination Net Unreachable
From 213.231.131.105 icmp_seq=5 Destination Net Unreachable
^C
--- 192.0.2.1 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4005ms
root@shemet:~$ ping 192.168.0.5
PING 192.168.0.5 (192.168.0.5) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
^C
--- 192.168.0.5 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3024ms
В софтуера за виртуализация трябва да имаш настройки на мрежата - там трябва да има зададена мрежа, в която трябва да са VPS-ите.
Дай да видим изхода ти и на двете машини:
iptables -L -v -n
root@shemet:~$ iptables -L -v -n
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
19622 5063K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- !lo * 127.0.0.0/8 0.0.0.0/0 LOG flags 0 level 4
0 0 DROP all -- !lo * 127.0.0.0/8 0.0.0.0/0
21125 6948K ACCEPT all -- eth0 * 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- eth1 * 0.0.0.0/0 255.255.255.255
1212 289K ACCEPT all -- eth0 * 1.2.3.0/24 0.0.0.0/0
965K 273M ACCEPT all -- eth1 * 192.168.0.0/24 0.0.0.0/0
0 0 ACCEPT !tcp -- eth0 * 0.0.0.0/0 224.0.0.0/4
0 0 ACCEPT !tcp -- eth1 * 0.0.0.0/0 224.0.0.0/4
0 0 LOG all -- ppp0 * 1.2.3.0/24 0.0.0.0/0 LOG flags 0 level 4
0 0 DROP all -- ppp0 * 1.2.3.0/24 0.0.0.0/0
0 0 LOG all -- ppp0 * 192.168.0.0/24 0.0.0.0/0 LOG flags 0 level 4
0 0 DROP all -- ppp0 * 192.168.0.0/24 0.0.0.0/0
0 0 LOG all -- ppp1 * 1.2.3.0/24 0.0.0.0/0 LOG flags 0 level 4
0 0 DROP all -- ppp1 * 1.2.3.0/24 0.0.0.0/0
0 0 LOG all -- ppp1 * 192.168.0.0/24 0.0.0.0/0 LOG flags 0 level 4
0 0 DROP all -- ppp1 * 192.168.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- ppp0 * 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- ppp1 * 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- ppp0 * 0.0.0.0/0 178.239.234.63
215M 11G ACCEPT all -- ppp1 * 0.0.0.0/0 178.239.230.240
111 9324 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4
111 9324 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 192.168.0.0/24 1.2.3.0/24
0 0 ACCEPT all -- * * 1.2.3.0/24 192.168.0.0/24
0 0 ACCEPT all -- eth0 ppp0 1.2.3.0/24 0.0.0.0/0
0 0 ACCEPT all -- eth1 ppp0 192.168.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- eth0 ppp1 1.2.3.0/24 0.0.0.0/0
63M 76G ACCEPT all -- eth1 ppp1 192.168.0.0/24 0.0.0.0/0
31M 8423M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 LOG all -- * ppp0 0.0.0.0/0 1.2.3.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp0 0.0.0.0/0 1.2.3.0/24
0 0 LOG all -- * ppp0 0.0.0.0/0 192.168.0.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp0 0.0.0.0/0 192.168.0.0/24
0 0 LOG all -- * ppp1 0.0.0.0/0 1.2.3.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp1 0.0.0.0/0 1.2.3.0/24
0 0 LOG all -- * ppp1 0.0.0.0/0 192.168.0.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp1 0.0.0.0/0 192.168.0.0/24
45 3396 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4
45 3396 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
19622 5063K ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- * eth0 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- * eth1 0.0.0.0/0 255.255.255.255
1212 289K ACCEPT all -- * eth0 0.0.0.0/0 1.2.3.0/24
446K 57M ACCEPT all -- * eth1 0.0.0.0/0 192.168.0.0/24
0 0 ACCEPT !tcp -- * eth0 0.0.0.0/0 224.0.0.0/4
0 0 ACCEPT !tcp -- * eth1 0.0.0.0/0 224.0.0.0/4
0 0 LOG all -- * ppp0 0.0.0.0/0 1.2.3.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp0 0.0.0.0/0 1.2.3.0/24
0 0 LOG all -- * ppp0 0.0.0.0/0 192.168.0.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp0 0.0.0.0/0 192.168.0.0/24
0 0 LOG all -- * ppp1 0.0.0.0/0 1.2.3.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp1 0.0.0.0/0 1.2.3.0/24
0 0 LOG all -- * ppp1 0.0.0.0/0 192.168.0.0/24 LOG flags 0 level 4
0 0 DROP all -- * ppp1 0.0.0.0/0 192.168.0.0/24
0 0 ACCEPT all -- * ppp0 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- * ppp1 0.0.0.0/0 255.255.255.255
0 0 ACCEPT all -- * ppp0 178.239.234.63 0.0.0.0/0
389M 553G ACCEPT all -- * ppp1 178.239.230.240 0.0.0.0/0
77 5226 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4
77 5226 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
ето и на виртуалната
root@unborn:/# w
14:38:38 up 21:44, 0 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root@unborn:/# iptables -L -v -n
Chain INPUT (policy ACCEPT 15 packets, 1010 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 171 packets, 13730 bytes)
pkts bytes target prot opt in out source destination
Първо спри firewalla:
/etc/init.d/iptables stop
След което добави това правило в iptables:
iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
Трябва да е достатъчно да можеш да пингнеш този ип адрес от виртуалната машина: 8.8.8.8
root@shemet:~$ /etc/init.d/iptables
-bash: /etc/init.d/iptables: No such file or directory
нямам firewall а добавих онова правило и няма никакъв ефект
» Безплатен продуктов ключ заWindows 7
» как да възстановя иконата на скайпа
» не работи преводач на думи в google toolbar ie11 window7
» как да свалям играта стани богат
» При стартиране на инсталиран Viber
» Не мога да инсталирам Скайп
» Защо не се активира английската(американска)клавиатура на Самсунг тренд2 от настройките?
» Програма за сваляне на снимки от LG L5 II Android - телефон
» Кажете ми някоя програма за андроид която може да промени гласа ( например когато се обаждам на някой)