Jump to content
BulForum.com

Помощ за едни команди...


daddydj

Recommended Posts

Здравейте!

Използвам Suse 9.2 и за да имам интернет на втория компютър

трябва да въведа следните команди:

iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P POSTROUTING ACCEPT

iptables -t nat -P OUTPUT ACCEPT

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

cd /etc/sysconfig/network

GATEWAYDEV=eth2

FORWARD_IPV4=true

 

Но трябва да ги пиша всеки път щом пусна РС-то. В кой файл

трябва да ги добавя за да се стартират заедно със системата?

Link to comment
Share on other sites

saszavash fail touch iptables_moi v /etc/rc.d/

 

#!/bin/sh

iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P POSTROUTING ACCEPT

iptables -t nat -P OUTPUT ACCEPT

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

cd /etc/sysconfig/network

GATEWAYDEV=eth2

FORWARD_IPV4=true

 

 

posle v boot.local pishesh

/etc/rc.d/iptables_moi start;

 

posle otivash v /etc/rc.d/ i pishesh tova chmod a+x iptables_moi

Link to comment
Share on other sites

saszavash fail  touch iptables_moi v /etc/rc.d/

 

#!/bin/sh

iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P POSTROUTING ACCEPT

iptables -t nat -P OUTPUT ACCEPT

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

cd /etc/sysconfig/network

GATEWAYDEV=eth2

FORWARD_IPV4=true

posle v boot.local pishesh

/etc/rc.d/iptables_moi start;

 

posle otivash v /etc/rc.d/ i pishesh tova chmod a+x iptables_moi

 

 

Направих всичко, но при буутването ми се появява следната грешка:

"Bad interpretor: No such file or directoryoi: /bin/sh"

Link to comment
Share on other sites

vij tova

na fedora1 stana

 

This is a how-to about sharing the internet via a linux box to the rest of your internal network.

 

In windows this is know as ICS (Internet Connection Sharing).

In linux it is called NAT (Network Address Translation).

 

1. On the linux box (that is directly connected to the internet, and is supposed to do the internet sharing),

start a terminal. Run the command su and then type the root password to become root.

 

2. Open the file /etc/rc.d/rc.local in your favorite text editor and add this on a new line at the bottom

/etc/rc.d/rc.ipmasq and save the file.

 

3. Then, create a new file called rc.ipmasq in the /etc/rc.d/ directory and open this file in a text editor and

add these lines

 

 

 

#!/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 eth0 -j MASQUERADE

 

# enable IP forwarding (of incoming packets)

echo 1 > /proc/sys/net/ipv4/ip_forward

 

 

 

Save this file.

 

This script assumes that eth0 is the ethernet adaptor connected to the internet (say, thru a DSL/cable modem). Change it

depending on your configuration (eth1, eth2 and so on). If the connection to the internet is not thru an ethernet device

(as in the case of ordinary dialup or USB modem), you have to use ppp0 (or ppp1, ppp2 and so on).

The network connections to the internet and intranet should already be up (how to do that is outside the scope of this

document).

 

4. Make this script file executable by running chmod 755 /etc/rc.d/rc.ipmasq

 

5. Then run the command /etc/rc.d/rc.ipmasq to enable the internet sharing.

 

6. Now you can stop being root by running exit

 

The above script will work after the following have been already done:

 

Set up the network on all the computers in the LAN. Make sure every computer can be reached from another computer by

"ping".

On each client computer, set the gateway to the internal IP address of the linux computer that is connected directly to

the internet. Under DNS put in the primary and/or secondary DNS IP addresses of your ISP (Internet Service Provider).

Link to comment
Share on other sites

Направих всичко, но при буутването ми се появява следната грешка:

"Bad interpretor: No such file or directoryoi: /bin/sh"

 

 

 

Написа ли това в скрипта отгоре!

#!/bin/sh

Още нещо провери дали sh ти е средата по default

Link to comment
Share on other sites

Написа ли това в скрипта отгоре!

#!/bin/sh

Още нещо провери дали sh ти е средата по default

Да горното е написано в в скрипта. Може ли да обясните как да разбера дали sh е средата по default?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...