Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
# ifconfig gif0 create
# ifconfig gif0 internal1 internal2
# ifconfig gif0 tunnel external1 external2
  • what is internal 1 and internal 2 IP? in freebsd
  • what is external 1 and external 2 IP? in freebsd

And how can I know my public IP?

share|improve this question

migrated from serverfault.com Dec 21 '12 at 14:37

This question came from our site for system and network administrators.

1 Answer 1

Note: This assumes you have normal networking running on two sites and want a tunnel between them.

Run ifconfig -a inet on each of the end-point machines. You should see the IP addresses of all interfaces along with some other information.

Similar to this on my local end:

lan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 
    options=3<RXCSUM,TXCSUM>
    inet 192.168.0.1 netmask 0xffffffc0 broadcast 192.168.0.254
wan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    inet 192.0.2.163 netmask 0xffffff00 broadcast 255.255.255.255

So my internal IP is 192.168.0.1, and external is 192.0.2.163.

On the remote end of my connection I do the same command and see:

lan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 
    options=3<RXCSUM,TXCSUM>
    inet 192.168.4.1 netmask 0xffffffc0 broadcast 192.168.4.254
wan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    inet 198.51.100.44 netmask 0xffffff00 broadcast 255.255.255.255

So the remote end's internal is 192.168.4.1 and external is 198.51.100.44.

On my local end I would run:

ifconfig gif0 create 192.168.0.1 192.168.4.1
ifconfig gif0 tunnel 192.0.2.163 198.51.100.44

On the remote end I would run

ifconfig gif0 create 192.168.4.1 192.168.0.1
ifconfig gif0 tunnel 198.51.100.44 192.0.2.163

This configuration is only temporary, once you reboot the machines the configuration will be lost. To make this configuration permanent, I would open /etc/rc.conf in my favorite editor and add the following:

On my local end:

network_interfaces="auto"
gif_interfaces="gif0"
gifconfig_gif0="192.0.2.163 198.51.100.44"
ifconfig_gif0"="inet 192.168.0.1/30 192.168.4.1"

On my remote end:

network_interfaces="auto"
gif_interfaces="gif0"
gifconfig_gif0="198.51.100.44 192.0.2.163"
ifconfig_gif0"="inet 192.168.4.1/30 192.168.0.1"

More notes:

  1. This does not setup routing. These two computer will know how to talk to each other, and nothing else. If you want routing you'll have to configure static routes, or configure a routing daemon like routed (the RIP daemon built into FreeBSD).
  2. This does not setup encryption. This is only the tunnel itself. If you want encryption you'll have to setup IPSec, and I'd highly recommend using ipsec-tools security port; which includes racoon, an IKE daemon.
  3. While it's technically possible to run a tunnel through a NAT firewall, I highly recommend avoiding that. It will be much more trouble than it's worth. Another note on NAT, if you're using one of FreeBSD's firewalls you can avoid that NAT, so it's not a problem. Also, you have to open specific ports and protocols if you have your firewall enabled to make the above work.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.