TCP/IP ports necessary for CIFS/SMB operation
Solution 1
Ports 137-139 are for NetBios/Name resolution. Without it you will have to access machines by IP address opposed to NetBIOS name. Example \\192.168.1.100\share_name
opposed to \\my_file_server\share_name
So port 445 is sufficient if you can work with IP addresses only.
Solution 2
This configuration worked for me: 137/UDP, 138/UDP, 139/TCP and 445/TCP. Source and additional information at: http://www.icir.org/gregor/tools/ms-smb-protocols.html.
So these are the iptables rules for my Samba server:
# The router doesn't need SMB access.
-A INPUT -s 192.168.1.1 -p udp --dport 137 -j REJECT
-A INPUT -s 192.168.1.1 -p udp --dport 138 -j REJECT
-A INPUT -s 192.168.1.1 -p tcp --dport 139 -j REJECT
-A INPUT -s 192.168.1.1 -p tcp --dport 445 -j REJECT
# Actual Samba ports
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 137 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 138 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 139 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 445 -j ACCEPT
Related videos on Youtube
Dora
Updated on September 18, 2022Comments
-
Dora almost 2 years
I'm totally new to Tkinter, so apologies if I'm saying something really wrong. I am implementing game fifteen in Python, which I wanna make visual with Tkinter. See the following board of 2x2:
4 3
2 xIf you prompt x to swop with 3, those labels should be updated.So far I initialised a canvas, and have two code snippets, one to set up the board:
def visualize(): for i,row in enumerate(board): for j,column in enumerate(row): L = Label(root,text=' %s '%board[i][j],bg='pink') if board[i][j] == d*d: L = tk.Label(root,text=' ')
And for the move function:
def move(): tile = int(raw_input('Which tile would you like to move: ')) global board, blankx, blanky for i in range(d): for j in range(d): if(board[i][j] == tile): if(i - 1 == blanky or i + 1 == blanky or j - 1 == blankx or j + 1 == blankx): board[i][j] = d * d board[blanky][blankx] = tile blanky = i blankx = j return True return False
Any ideas on how to incorporate the labels into my canvas, and how to incorporate move as a valid event on the canvas? Thanks a lot
-
Jonathan over 12 yearsAt my site, NetBIOS names are always the same as DNS names. So if I refer to machines by hostname, will Windows be able find the machine through DNS without using NetBIOS?
-
Tim over 12 yearsAs long as you have functioning DNS available to the client it should suffice.
-
Dora over 8 yearsThanks a lot, this is really useful! I was wondering whether you know how I could put this into a ' while won() == False: ' so that the game only goes on until the game is solved? It's not working the way I'm trying with simple including this Tkinter snippet into the loop.
-
furas over 8 years
mainloop()
should be the only (endless) loop in Tkinter. I think you should't usewhile won() == False:
. Better inmove()
useif won(): print("Hurray!")
-
furas over 8 yearsI modified code to add
won()
function and"Hurray"
label. I useFrame
to easily hide all buttons behind label. It still needsshuffle()
function. -
Dora over 8 yearsThanks a lot, saved me a lot of frustration. I did it with labels in the end, and now im trying to work on resetting the board. I thought shuffle() could be the same as init where I set the values for board[i][j]. But it seems like by clicking anywhere after winning, the board stays the same, however the values do go back to the initial board values. I thought after shuffling though the mainloop() will restart itself, and the board will again be set up according to the new (initial) board values. Any idea on where I'm wrong?
-
furas over 8 yearsif you have
board
with new values then you have to use it to change buttons text -buttons[y][x]['text'] = board[y][x]
-
furas over 8 yearsyou can use
tkinter.StringVar()
in board to keep values and assignStringVar()
toButton
usingtextvariable=
instead oftext=
. When you change value inStringVar
in board it will change text on button. -
furas over 8 yearsI made new version with StringVar - see new code in answer.
-
Dora over 8 yearsThanks for the updates! Okay, didn't work with merely updating the text label for me. I'm trying to initialize the board (that's given in yours). I want it to be according to the user's input as dimension. Not too familiar with stringvars, but I can't just append it to a list, it seems like. Can you help me with that please? Rest looks fine after the initialization
-
furas over 8 yearsyou can use
StringVar()
as other objects. You assign it to variablesome_stringvar_text = StringVar()
or append to listsome_list.append(StringVar())
orsome_list.append(some_stringvar_text)
. But you have to useget()
andset()
likeprint(some_stringvar_text.get())
andsome_stringvar_text.set("Hello")
. If you have problem then put code on pastebin.org or ideone.com and send link (like this pastebin.com/p2KAfsHH ). -
Dora over 8 yearsThat might be a better idea:) Here it is: pastebin.com/MVXjk1fV Really appreciate your help! The messy part is the setup function. Now the board seems to be fine, but visually it doesn't show that on the window.
-
Dora over 8 yearsThanks for this, I changed a few details as it wasn't displaying, and it all works fine. Except one thing: in setup(): I say button.lower() to make it disappear once clicked, but button is a non-referenced variable. So I can't make it disappear after resetting the board. Making it global won't work either.. I just wonder why this is while button.lift() was fine in the play() method
-
furas over 8 yearsshow code. In previous version there is no
button
variable butlabel
and it is reference toButton
. Maybe you get error message (in console) which could help. -
Dora over 8 yearspastebin.com/B6Vq3w6R In setup() for bn.lower() I get: "global name 'bn' is not defined"
-
furas over 8 yearsnow I see -
setup()
have to be afterbn=Button()
. Now you callsetup() before you create
bn` variablem. Remove firstsetup()
- leave secondsetup()
- you don't have to call it twice. -
Dora over 8 yearsGooooot it!! There was an extra function call right before root = tk.Tk() ! Thank you :)
-
furas over 8 yearscode: pastebin.com/C303uP6U . You don't need
buttons = []
any more. You can removegame_running = True
beforemainloop()
becausesetup()
setsgame_running = True
-
Samuel Harmer almost 8 years@Hrqls In theory, yes, but AFAIK opening up your SMB to the whole world is a very bad idea.
-
DarkMoon over 7 yearsGiven that the OP asked about Windows computers and their level of understanding of iptables is completely unknown, this would be better written out than as a completely different system's configuration file.
-
Gabor over 5 yearsIn plain English, UDP 137 and 138, TCP 139 and 445
-
dess over 4 years@Styne666 , totally agree. Even more: opening anything, which does not have adequate security support, to the whole Internet is generally bad idea. I would recommend to use IPsec transport mode to protect it at least.
-
Feriman over 3 yearsIf you are access to this remote machine with DDNS, allow only TCP 445 because it's enough. I tested it today and works well.