![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.
|
|
Networking & Wireless Having problems getting connected to the internet or getting your wireless card to work? Ask here. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Grande Half-n-Half Cinnamon Ubuntu
![]() Join Date: Apr 2007
Location: Germany
Beans: 947
Ubuntu 9.04 Jaunty Jackalope
|
I keep reading that people want to share their internet connection through an Ubuntu computer. So, i will put down a few basic steps that one has to do to turn any ubuntu installation into a basic gateway for other computers.
The Settings i am going to write down here are permanent ! so please remember this if you use a mobile device that it will always (!) act as a gateway for the configured network card. In the following, i will refer to the network device that is connected to the internet as eth1. It is not compulsory that the internet device is called that - other possible names are: eth0, ath0, ppp0, ... and many more. The computer/network with the clients is, in my case, connected to the network device eth0. This can also vary quite a lot, too. Please make sure you know what device is which for you, and adjust all commands and configurations accordingly. The basic scheme of what this setup looks like is: PC-Client <---> PC-Gateway (ubuntu) <---> Internet Prerequisites Your ubuntu Computer has internet connection and you know which network device provides this functionality. NOTE: how you are connected to the internet does not matter (ethernet, cable, wifi, dsl), as long as you have a second network device besides the one you are connection this should work. Configuring the network card the network card that serves the clients (eth0) needs a static ip address. This can be done outside of network manager and would be recommended that way, since you might need nm to still connect the gateway to the internet itself. Note that this will result in network-manager to completely ignore the network card that you configured for the client network, thus rendering eth0 unavailable in nm. edit the network configuration file and set eth0 to a static ip. to open the config use this command Code:
gksu /etc/network/interfaces add the following lines to the file Code:
auto eth0
iface eth0 inet static
address 10.8.16.1
netmask 255.255.255.0
broadcast 10.8.16.0
network 10.8.16.0
Code:
sudo ifconfig eth0 10.8.16.1 Port forwarding is turned off in ubuntu by default. But it is needed so that the Computer will forward pakets it receives. To enable port forwarding, issue the following command Code:
gsku gedit /etc/sysctl.conf Code:
#net.ipv4.conf.default.forwarding=1 Code:
net.ipv4.conf.default.forwarding=1 Code:
sudo sysctl -w net.ipv4.ip_forward=1 it has been reported multiple times that the sysctl.conf got ignored. You can check that issueing this command after a reboot: Code:
sudo sysctl net.ipv4.ip_forward Code:
sudo gedit /etc/rc.local Code:
sysctl -w net.ipv4.ip_forward=1 [/Update] Configuring iptables (paket filter) In order to allow pakets to pass though the router, we need to add a couple of iptables rules to the filter so that everything may pass our machine. Also we need to rewrite the pakets so that they can find their way back to us. open the file /etc/rc.local with Code:
gksu gedit /etc/rc.local Code:
/sbin/iptables -P FORWARD ACCEPT /sbin/iptables --table nat -A POSTROUTING -o eth1 -j MASQUERADE again, these changes only take effect after a reboot. to make the changes take effect right now, use these commands Code:
sudo iptables -P FORWARD ACCEPT sudo iptables --table nat -A POSTROUTING -o eth1 -j MASQUERADE There are two ways to configure the client - one is a static, manual config. If you would like to do this, then give the client an ip-address in the network 10.8.16.0/24 (i.e. 10.8.16.2), the gateway 10.8.16.1 and a dns server from your computer (they can be found in the file /etc/resolv.conf) If you have multiple client, or do not want to configure something staticially, you might want to look at setting up a basic dhcp server which issues network configurations to clients. to install the server, type the following Code:
sudo apt-get install dhcp3-server before the dhcp server itself can be configured, we need one more little bit of information. We need to know what dns servers are used so we can push then to the clients that will be configured via this server. to find out the currently used dns server, use this command Code:
cat /etc/resolv.conf The next step is to configure the dhcp-server so it knows what ip-addresses to dish out and what settings. for that, edit the file /etc/dhcp3/dhcpd.conf with this command Code:
gksu gedit /etc/dhcp3/dhcpd.conf Code:
ddns-update-style none;
option domain-name "mynetwork";
option domain-name-servers Nameserver1, Nameserver2;
option routers 10.8.16.1;
default-lease-time 42300;
max-lease-time 84600;
authoritative;
log-facility local7;
subnet 10.8.16.0 netmask 255.255.255.0 {
range 10.8.16.50 10.8.16.150;
}
the last thing to do before the server can be started is to tell it what interface to listen on. This can be configures in the file /etc/default/dhcp3-server. open it with Code:
gksu gedit /etc/default/dhcp3-server Code:
INTERFACES="eth0" Code:
sudo /etc/init.d/dhcp3-server start Please be reminded that you need to always check the network devices in your computer aginst the ones in the config. If you configure blindly from this and your devices are swapped or named different, you can break you computers network entirely.
__________________
Calvin: I'm being educated against my will! My rights are being trampled! Hobbes: Is it a right to remain ignorant? Calvin: I don't know, but I refuse to find out! Last edited by SpaceTeddy; June 30th, 2008 at 12:38 PM.. Reason: Update for enableing ipforwarding |
|
|
|
|
|
#2 |
|
Way Too Much Ubuntu
![]() Join Date: Dec 2007
Location: Ukraine
Beans: 305
Ubuntu 7.10 Gutsy Gibbon
|
Re: HOWTO: Internet sharing with Ubuntu (NAT Gateway)
ok i did do that spaceteddy but it returns a 0 so it is not enabled...here is my file.
Code:
# # /etc/sysctl.conf - Configuration file for setting system variables # See sysctl.conf (5) for information. # #kernel.domainname = example.com #net/ipv4/icmp_echo_ignore_broadcasts=1 # the following stops low-level messages on console kernel.printk = 4 4 1 7 # enable /proc/$pid/maps privacy so that memory relocations are not # visible to other users. kernel.maps_protect = 1 ##############################################################3 # Functions previously found in netbase # # Uncomment the next line to enable Spoof protection (reverse-path filter) #net.ipv4.conf.default.rp_filter=1 # Uncomment the next line to enable TCP/IP SYN cookies #net.ipv4.tcp_syncookies=1 # Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.conf.default.forwarding=1 # Uncomment the next line to enable packet forwarding for IPv6 #net.ipv6.conf.default.forwarding=1
__________________
linux help site www.linuxlogik.com Web and graphics designwww.OnTheDotWebDesign.com SUPER HOSTING!www.Onthedotwebdesign.com/hosting.html Intel Core2 Quad Q6600 OC to 3.0 GHz, 4GB DDR2-800, MSI P35 Neo2, ATI HD2600PRO SUPER |
|
|
|
|
|
#3 |
|
Dark Roasted Ubuntu
![]() Join Date: Jan 2008
Location: Cambridge MA
Beans: 1,151
Ubuntu 9.10 Karmic Koala
|
Re: HOWTO: Internet sharing with Ubuntu (NAT Gateway)
So I didn't use the walkthrough above to enable internet sharing, I used firestarter. I was able to get it so that my local machines can all ping each other but I don't get internet sharing from my server machine to the clients. Anybody know what I might need to do?
__________________
Allons-y Alonzo! - The Dr. Is that what Time Lords do? Lop a bit off, and grow another one. You're like worms! - Donna Noble The world is a mess... and I just need to... Rule it. - Dr. Horrible
|
|
|
|
|
|
#4 |
|
Dark Roasted Ubuntu
![]() Join Date: Jan 2008
Location: Cambridge MA
Beans: 1,151
Ubuntu 9.10 Karmic Koala
|
Re: HOWTO: Internet sharing with Ubuntu (NAT Gateway)
I was having a DNS issue. Firestarter worked great for me!
__________________
Allons-y Alonzo! - The Dr. Is that what Time Lords do? Lop a bit off, and grow another one. You're like worms! - Donna Noble The world is a mess... and I just need to... Rule it. - Dr. Horrible
|
|
|
|
|
|
#5 |
|
自己犠牲の精神
![]() Join Date: Mar 2006
Location: Kitakyushu Japan
Beans: 7,891
Xubuntu 8.04 Hardy Heron
|
Re: HOWTO: Internet sharing with Ubuntu (NAT Gateway)
/etc/sysctl.conf needs two lines for proper ipv4 forwarding:
Code:
net.ipv4.conf.default.forwarding=1 net.ipv4.conf.all.forwarding=1 More information here: https://help.ubuntu.com/community/In...nectionSharing
__________________
1) Samba server howto in progress | 2) mount windows/samba shares with CIFS + unicode | 3) best FTP server howto
4) NFS server/client howto | 5) Easy cross-platform LAN file sharing with FTP 6) Fix samba browsing!!! | 7) Fix Pulse audio Happy Ubunting!![]() |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|