next up previous contents
Next: Open VPN Up: SoftEther VPN Previous: vpncmd 設定 vpn client   Contents

設定 VPN Client IP

  1. 查看 vpn_myadapter 沒有指定 IP,無法連線 VPN server 端的 192.168.1.254。
    [root@dywftp vpnclient]# ifconfig vpn_myadapter
    vpn_myadapter Link encap:Ethernet  HWaddr 00:AC:E8:A9:C9:4D  
              inet6 addr: fe80::2ac:e8ff:fea9:c94d/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:290 errors:0 dropped:0 overruns:0 frame:0
              TX packets:245 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:20090 (19.6 KiB)  TX bytes:20254 (19.7 KiB)
    
    [root@dywftp vpnclient]# ping -c3 192.168.1.254
    PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
    
    --- 192.168.1.254 ping statistics ---
    3 packets transmitted, 0 received, 100% packet loss, time 11999ms
    
  2. 設定 vpn_myadapter IP 為 192.168.1.200/24,就可以連線 VPN server 端的 192.168.1.254。
    [root@dywftp vpnclient]# ifconfig vpn_myadapter 192.168.1.200/24
    [root@dywftp vpnclient]# ping -c3 192.168.1.254
    PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
    64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=1.80 ms
    64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=0.643 ms
    64 bytes from 192.168.1.254: icmp_seq=3 ttl=64 time=0.603 ms
    
    --- 192.168.1.254 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    rtt min/avg/max/mdev = 0.603/1.015/1.801/0.556 ms
    
  3. 在 Linux 要由 VPN server 的 DHCP 自動取得 vpn_myadapter 的 IP,可以使用 dhclient 命令。
    [root@dywftp ~]# dhclient vpn_myadapter &
    [1] 22730
    [root@dywftp ~]# ifconfig vpn_myadapter
    vpn_myadapter Link encap:Ethernet  HWaddr 00:AC:E8:A9:C9:4D  
              inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::2ac:e8ff:fea9:c94d/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:6701 errors:0 dropped:0 overruns:0 frame:0
              TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:416312 (406.5 KiB)  TX bytes:11980 (11.6 KiB)
    
    [1]+  Done                    dhclient vpn_myadapter
    
  4. vpn_myadapter 釋出取得的 IP,可以使用 dhclient -r 命令。
    [root@dywftp ~]# dhclient -r vpn_myadapter
    [root@dywftp ~]# ifconfig vpn_myadapter
    vpn_myadapter Link encap:Ethernet  HWaddr 00:AC:E8:A9:C9:4D  
              BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:6786 errors:0 dropped:0 overruns:0 frame:0
              TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:421539 (411.6 KiB)  TX bytes:12838 (12.5 KiB)
    
  5. 當 VPN Clinet 也是在 VLAN 且網段也是 192.168.1.0/24 時......


2018-03-16