Hoi, ik gebruik sinds een paar dagen Linux. Onlangs heb ik het voor elkaar gekregen om mijn Speedtouch USB modem (ppp0) succesvol te configureren. Nu wil ik echter een andere PC in mijn netwerk (op eth0) mee laten genieten van dit succes en het internet delen.
Ik dacht dit te doen met de configuratie, die onderaan deze post staat. Helaas blijkt dat de DNS adressen niet geforwarded worden, ik kan op het netwerk alleen internetten door IP nummers in te toetsen. Waarschijnlijk moet ik nog iets configureren, maar ik weet niet wat? Vandaar dat ik jullie hulp inschakel. Ik gebruik DHCPD om PC's een IP adres te laten toekennen, de gateway wordt goed overgenomen. De DNS servers in DHCPD heb ik overgenomen van /etc/resolv.conf.
Bestanden:
/etc/rc.d/rc.ipmasq (wordt aangeroepen vanuit /etc/rc.d/rc.local)
/etc/dhcpd.conf
Ik dacht dit te doen met de configuratie, die onderaan deze post staat. Helaas blijkt dat de DNS adressen niet geforwarded worden, ik kan op het netwerk alleen internetten door IP nummers in te toetsen. Waarschijnlijk moet ik nog iets configureren, maar ik weet niet wat? Vandaar dat ik jullie hulp inschakel. Ik gebruik DHCPD om PC's een IP adres te laten toekennen, de gateway wordt goed overgenomen. De DNS servers in DHCPD heb ik overgenomen van /etc/resolv.conf.
Bestanden:
/etc/rc.d/rc.ipmasq (wordt aangeroepen vanuit /etc/rc.d/rc.local)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
| #!/bin/sh IPTABLES=/sbin/iptables #All The lines below are NAT routing # flush any old rules $IPTABLES -F -t nat # turn on NAT (IP masquerading for outgoing packets) $IPTABLES -A POSTROUTING -t nat -o ppp0 -j MASQUERADE # enable IP forwarding (of incoming packets) echo 1 > /proc/sys/net/ipv4/ip_forward |
/etc/dhcpd.conf
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| #These lines are for lease times and for update style.
#These do not need to be changed for normal operation
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
# Change the subnet mask to the subnet mask of your network
# In most cases for a small network it will be 255.255.255.0
option subnet-mask 255.255.255.0;
# Change this to the IP address of the computer that is connected to the internet
# In most cases this will be the same as the computer as this script is running on
option routers 192.168.1.1;
# Change this to the IP addresses of the primary and secondary
# DNS servers of your ISP (internet service provider)
option domain-name-servers 195.121.1.34, 195.121.1.66;
# This is the range of IP address that will be given out. It’s best
# To use the 192.168.0.0 range as this is set aside for none internet networks
# This will hand out IPs address in the range of 192.168.0.10 to 192.168.0.255
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.80;
range 192.168.1.128 192.168.1.254;
}
#The NIC with this MAC address will always get the same IP address 192.168.03
host NAME_OF_HOST {
# NAME_OF_HOST should be changed to the name of that computer.
hardware ethernet 00:0C:6E:E2:77:67;
fixed-address 192.168.1.1;
} |