Sharing Internet between Linux and GhostBSD (or other OS)

Configuring and tweaking your GhostBSD System.

Sharing Internet between Linux and GhostBSD (or other OS)

Postby ASX » Mon Aug 29, 2016 4:08 pm

I'm usually connected to Internet thru my WiFi router.
It happens sometimes I need to test/install GhostBSD on some machine that doesn't have a WiFi adapter at all, in this case I connect the GhostBSD machine to my Linux connected machine:

[ Internet ] <-> [ wifi router ] <-> [ Linux ] <- ethernet cable -> [ GhostBSD (or other OS) ]

Note: You can use a straight 1 to 1 cable if both eth devices support autosensing, this is the case for Gigabit capable eth devices, otherwise you need to use a crossed cable when using older non-autosensing eth devices.

How is shared the connection: by using iptables filters.

Code: Select all
# Generated by iptables-save v1.6.0 on Mon May  9 18:10:38 2016
*filter
:INPUT ACCEPT [1:118]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:130]
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i enp7s0 -o wlp6s0 -j ACCEPT
COMMIT
# Completed on Mon May  9 18:10:38 2016
# Generated by iptables-save v1.6.0 on Mon May  9 18:10:38 2016
*nat
:PREROUTING ACCEPT [34:4882]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o wlp6s0 -j MASQUERADE
COMMIT
# Completed on Mon May  9 18:10:38 2016


I'm running Arch, however iptables is widely used in many Linux distros

enp7s0 is the name of my Linux Eth device (usually named eth0)
wlp6s0 is the name of my Linux Wifi device (usually named wlan0)
the wifi network is: 192.168.1.0/24 and the wifi card has an address in that range, say 192.168.1.1
the eth network is: 192.168.2.0/24 and the eth device has an address in that range, say 192.168.2.254

be sure to start the iproute service, command may vary depending on your init system.

That's all on Linux side.

~~~

On the GhostBSD machine the INET address must be manually set to something in eth network range, say 192.168.2.1
and set the DEFAULTROUTER to 192.168.2.254 which act as a gateway.

issue the following two commands, and your GhostBSD machine is ready to go:

Code: Select all
/etc/rc.d/netif restart
/etc/rc.d/routing restart


Also, do do forget to set some DNS, say 8.8.8.8 or 8.8.4.4 (google dns)
ASX
Developer
 
Posts: 856
Joined: Wed May 06, 2015 11:46 am
Location: ITALY
Has thanked: 49 times
Been thanked: 108 times

Sharing Internet between Linux and GhostBSD (or other OS)


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 2 guests