IPsec/IKEv2-based VPN software for Linux
Setup a physical interface.
# sudo ifconfig eth0 192.168.0.10 netmask 255.255.255.0 Add a default route. # sudo route add default gw 192.168.0.1 Enable IPv4 routing. # sudo sysctl net.ipv4.ip_forward=1 |
Setup physical interfaces.
eth0 and a routing table are configured according to your service provider's instructions. # sudo ifconfig eth0 10.0.0.2 netmask 255.255.255.0 # sudo ifconfig eth1 192.168.1.10 netmask 255.255.255.0 Enable IPv4 routing. # sudo sysctl net.ipv4.ip_forward=1 |
Setup physical interfaces.
eth0 and a routing table are configured according to your service provider's instructions. # sudo ifconfig eth0 10.0.0.3 netmask 255.255.255.0 # sudo ifconfig eth1 192.168.2.10 netmask 255.255.255.0 Enable IPv4 routing. # sudo sysctl net.ipv4.ip_forward=1 |
Setup physical interfaces.
eth0 and a routing table are configured according to your service provider's instructions. # sudo ifconfig eth0 10.0.0.1 netmask 255.255.255.0 # sudo ifconfig eth1 192.168.0.1 netmask 255.255.255.0 Enable IPv4 routing. # sudo sysctl net.ipv4.ip_forward=1 Forward packets destinated to 10.0.0.1:500(Router1) to 192.168.0.10:500(HubGw). # sudo iptables -t nat -A PREROUTING -p udp --dst 10.0.0.1 --dport 500 -j DNAT --to-destination 192.168.0.10:500 Forward packets destinated to 10.0.0.1:4500(Router1) to 192.168.0.10:4500(HubGw). # sudo iptables -t nat -A PREROUTING -p udp --dst 10.0.0.1 --dport 4500 -j DNAT --to-destination 192.168.0.10:4500 |
auto eth0
iface eth0 inet static address 192.168.0.10 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 |
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 10
Realm Name: "To MeshGw1"
Description: "Config for MeshGw1."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw1(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif10.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.1
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw1(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw1(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw1(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw0.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw1(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw1.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw1(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw1.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw1.example.com(FQDN) pane.
- Enter the following.
This peer's Network Deployment: Mesh Node
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 20
Realm Name: "To MeshGw2"
Description: "Config for MeshGw2."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 20:To MeshGw1(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif20.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.5
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 20:To MeshGw1(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 20:To MeshGw1(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 20:To MeshGw1(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw0.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 20:To MeshGw2(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw2.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 20:To MeshGw2(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw2.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw2.example.com(FQDN) pane.
- Enter the following.
This peer's Network Deployment: Mesh Node
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show "Edit
VPN Realm(Save, Add, Remove, or Load)" pane.
- Click Save Configuration button.
/etc/quagga/daemons |
zebra=yes
bgpd=no ospfd=yes ospf6d=no ripd=no ripngd=no isisd=no |
/etc/quagga/debian.conf |
vtysh_enable=yes
zebra_options=" --daemon -A 127.0.0.1" bgpd_options=" --daemon -A 127.0.0.1" ospfd_options=" --daemon -A 127.0.0.1" ospf6d_options="--daemon -A ::1" ripd_options=" --daemon -A 127.0.0.1" ripngd_options="--daemon -A ::1" isisd_options=" --daemon -A 127.0.0.1" |
/etc/quagga/vtysh.conf |
!service integrated-vtysh-config
hostname meshgw0 username root nopassword ! |
#sudo cp /usr/share/doc/quagga/examples/zebra.conf.sample /etc/quagga/zebra.conf #sudo cp /usr/share/doc/quagga/examples/ospfd.conf.sample /etc/quagga/ospfd.conf |
#sudo chown quagga:quaggavty /etc/quagga/*.conf #sudo chmod 640 /etc/quagga/*.conf |
#sudo /etc/init.d/quagga restart |
# sudo vtysh |
configure terminal
router ospf router-id 0.0.0.100 network 192.168.0.0/24 area 0.0.0.0 network 192.168.100.0/30 area 0.0.0.0 network 192.168.100.4/30 area 0.0.0.0 ! |
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 10
Realm Name: "To MeshGw0"
Description: "Config for MeshGw0."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif10.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.2
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw0(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw1.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw0(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw0.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw0.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw0.example.com(FQDN) pane.
- Enter the following.
Peer's IPv4 Address: 10.0.0.1 (Router1's global address)
- Network Deployment: Select Mesh Node.
Always-on connection: Check Enabled.
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 30
Realm Name: "To MeshGw2"
Description: "Config for MeshGw2."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw2(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif30.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.9
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 30:To MeshGw2(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw2(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw2(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw1.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 30:To MeshGw2(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw2.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw2(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw2.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw2.example.com(FQDN) pane.
- Enter the following.
Peer's IPv4 Address: 10.0.0.3
- Network Deployment: Select Mesh Node.
Always-on connection: Check Enabled.
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show "Edit
VPN Realm(Save, Add, Remove, or Load)" pane.
- Click Save Configuration button.
# sudo vtysh |
configure terminal
router ospf router-id 0.0.0.90 network 192.168.1.0/24 area 0.0.0.0 network 192.168.100.0/30 area 0.0.0.0 network 192.168.100.8/30 area 0.0.0.0 ! |
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 20
Realm Name: "To MeshGw0"
Description: "Config for MeshGw0."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif20.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.6
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw0(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw2.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 10:To MeshGw0(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw0.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 10:To MeshGw0(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw0.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw0.example.com(FQDN) pane.
- Enter the following.
Peer's IPv4 Address: 10.0.0.1 (Router1's global address)
- Network Deployment: Select Mesh Node.
Always-on connection: Check Enabled.
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show Edit VPN Realm(Save, Add, Remove, or Load) pane.
- Click Add VPN Realm button.
- Add a VPN Realm[Dialog]: Enter the following, then click OK button.
Realm ID: 30
Realm Name: "To MeshGw1"
Description: "Config for MeshGw1."
Mode: Router
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw1(Router)[Left-Tree]
> VPN Interface[Left-Tree]:
Click this tree node and show VPN Tunnel/TAP Interface pane.
- Enter the following. This address is for the virtual interface rhpvif30.
Internal Address Type: Static Address
Internal IPv4 Address: 192.168.100.10
Netmask: 255.255.255.252
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 30:To MeshGw1(Router)[Left-Tree] > Network Interface[Left-Tree]: Click this tree node and show Network Interface pane.
- Uncheck Use default route and enter the followings.
Primary interface:
- Name: Select eth0 as a source interface.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw1(Router)[Left-Tree]
> Service[Left-Tree]:
Click this tree node and show Service pane.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw1(Router)[Left-Tree]
> My Key Store[Left-Tree]:
Click this tree node and show My Key Store pane.
- Enter the following.
Authentication Method: RSA Signature(RSA-Sig)
My ID Type: auto
Imported Key Format: PKCS#12 - File
PKCS#12 file(*.p12): meshgw2.example.com.p12
RSA Private Key's Password: himitsu
- VPN Configuration[Tab] > VPN Realms[Left-Tree] > 30:To MeshGw1(Router)[Left-Tree] > Peers[Left-Tree]: Click this tree node and show Peers pane.
- Click Add Peer button.
Add a New Peer[Dialog]:
Enter the following, then click OK button.
Peer ID Type: IKEv2: Host Name(FQDN)
Peer ID: meshgw1.example.com
- VPN Configuration[Tab]
> VPN Realms[Left-Tree]
> 30:To MeshGw1(Router)[Left-Tree]
> Peers[Left-Tree] >
meshgw1.example.com(FQDN)[Left-Tree]:
Click this tree node and show Peer: meshgw1.example.com(FQDN) pane.
- Enter the following.
- Network Deployment: Select Mesh Node.
- VPN Configuration[Tab]
> Edit VPN Realm(Save, Add, etc.)[Left-Tree]:
Click this tree node and show "Edit
VPN Realm(Save, Add, Remove, or Load)" pane.
- Click Save Configuration button.
# sudo vtysh |
configure terminal
router ospf router-id 0.0.0.80 network 192.168.2.0/24 area 0.0.0.0 network 192.168.100.4/30 area 0.0.0.0 network 192.168.100.8/30 area 0.0.0.0 ! |
# sudo vtysh |
configure terminal
interface rhpvif30 ip ospf cost 100 ! router ospf .... ! |