ข่าว: ข่าวประกาศ

  • 27 เมษายน 2024, 16:16:59

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ผู้เขียน หัวข้อ: vtun : virtual tunnel over TCP/IP networks  (อ่าน 10702 ครั้ง)

admin

  • Administrator
  • Hero Member
  • *****
  • กระทู้: 3820
    • ดูรายละเอียด
    • อีเมล์
vtun : virtual tunnel over TCP/IP networks
« เมื่อ: 28 สิงหาคม 2010, 19:10:32 »
ระบบ VPN อย่างง่าย ๆ บน Ubuntu

หลายท่านอาจจะคิดว่า ระบบ VPN เป็นเรื่องยาก และเป็นเรื่องที่ซับซ้อน แต่มันจะง่ายขึ้นเมื่อได้พบกับ vtun

ก่อนอื่น ทำการติดตั้ง vtun ด้วยคำสั่ง

# apt-get install vtun

:=============================== ฝั่ง Server ===============================:

ให้ทำการ config  /etc/vtund.conf

options {
  port 5000;            # Listen on this port.
  syslog daemon;        # Syslog facility

  # Path to various programs
  ppp           /usr/sbin/pppd;
  ifconfig      /sbin/ifconfig;
  route         /sbin/route;
  firewall      /sbin/tables;
  ip            /sbin/ip;
}

# Default session options
default {
  type ether;            #tun, ether, tty(default), pipe
  proto tcp;           #udp, tcp
  compress yes;          # no, yes, zlib, lzo
  encrypt no;          #yes, no
  stat yes;             #yes, no: check /var/log/vtund/SessionName_X
  speed 0;              # By default maximum speed, NO shaping
}


# PPP tunnel example.
PPP-Tunnel {
  passwd  vpnpass;     # Password
  keepalive yes;       # Keep connection alive
  persist yes;

  up {
        # Connection is Up
   ifconfig "%% 10.0.0.1 netmask 255.255.255.252 up";
  };

  down {
        # Connection is down
  };
}

เสร็จแล้วก็เรียกใช้งานด้วยคำสั่ง

# vtund -s

:=============================== ฝั่ง Client ===============================:

ทำการ config /etc/vtund.conf

options {
  port 5000;            # Listen on this port.
  syslog daemon;        # Syslog facility

  # Path to various programs
  ppp           /usr/sbin/pppd;
  ifconfig      /sbin/ifconfig;
  route         /sbin/route;
  firewall      /sbin/tables;
  ip            /sbin/ip;
}

# Default session options
default {
  type ether;            #tun, ether, tty(default), pipe
  proto tcp;           #udp, tcp
  compress yes;          # no, yes, zlib, lzo
  encrypt no;          #yes, no
  stat yes;             #yes, no: check /var/log/vtund/SessionName_X
  speed 0;              # By default maximum speed, NO shaping
}


# PPP tunnel example.
PPP-Tunnel {
  passwd  vpnpass;     # Password
  keepalive yes;       # Keep connection alive
  persist yes;

  srcaddr {
        iface ppp101;
  };

  up {
        # Connection is Up
   ifconfig "%% 10.0.0.2 netmask 255.255.255.252 up";
  };

  down {
        # Connection is down
  };
}

เสร็จแล้วก็เรียกใช้งานด้วยคำสั่ง   vtund [ชื่อ session] [IP ฝั่ง Server]

# vtund PPP-Tunnel 112.121.123.123

เมื่อทำการเชื่อมต่อแล้ว ก็จะได้ interface เพิ่มขึ้นมา ชื่อ tap0

# ifconfig

125.26.246.1 dev ppp102  proto kernel  scope link  src 125.26.246.10
125.26.246.1 dev ppp104  proto kernel  scope link  src 125.26.247.188
125.26.246.1 dev ppp101  proto kernel  scope link  src 125.26.247.42
125.26.244.1 dev ppp103  proto kernel  scope link  src 125.26.244.161
10.0.0.0/30 dev tap0  proto kernel  scope link  src 10.0.0.2
192.168.200.0/24 dev eth0  proto kernel  scope link  src 192.168.200.250

# ifconfig tap0 (ฝั่ง Server)

tap0      Link encap:Ethernet  HWaddr 22:2e:57:69:d9:8d
          inet addr:10.0.0.1  Bcast:10.0.0.3  Mask:255.255.255.252
          inet6 addr: fe80::202e:57ff:fe69:d98d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:50 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:6912 (6.9 KB)  TX bytes:3690 (3.6 KB)


# ifconfig tap0  (ฝั่ง Client)

tap0      Link encap:Ethernet  HWaddr be:b5:02:3b:62:98
          inet addr:10.0.0.2  Bcast:10.0.0.3  Mask:255.255.255.252
          inet6 addr: fe80::bcb5:2ff:fe3b:6298/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:3690 (3.6 KB)  TX bytes:6912 (6.9 KB)


ก็เป็นอันเรียบร้อย สำหรับ vpn แบบง่าย ๆ ที่เหลือก็นำไปประยุกต์ใช้กันเอาเองนะครับ 

สามารถสร้าง vpn สำหรับเชื่อมสาขากันได้เหมือน network เดียวกัน

สามารถสร้าง bonding เพื่อรวมเน็ตได้ด้วยวิธีการเดียวกันนี้

และสามารถประยุกต์ได้อีกมากมายเลยครับ

 ;D ;D ;D ;D
« แก้ไขครั้งสุดท้าย: 28 สิงหาคม 2010, 19:14:58 โดย admin »
<a href="http://www.hadyaiinternet.com/images/inetcafe.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">http://www.hadyaiinternet.com/images/inetcafe.swf</a>


There are no comments for this topic. Do you want to be the first?